Java tutorial
//package com.java2s; import android.content.Context; import android.util.Base64; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.PrintStream; public class Main { public static void writeSObject(Context context, Object content, String path) { try { ByteArrayOutputStream e = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(e); oos.writeObject(content); String stringBase64 = new String(Base64.encode(e.toByteArray(), 0)); writeString(context, stringBase64, path); } catch (IOException var6) { var6.printStackTrace(); } } public static void writeString(Context context, String content, String path) { try { FileOutputStream fos = context.openFileOutput(path, Context.MODE_PRIVATE); PrintStream ps = new PrintStream(fos); ps.print(content); ps.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }