Here you can find the source of saveObject(Context context, String fileName, Object obj)
public static void saveObject(Context context, String fileName, Object obj) throws IOException
//package com.java2s; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import android.content.Context; public class Main { public static void saveObject(Context context, String fileName, Object obj) throws IOException { FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); ObjectOutput out = null;//from ww w . ja v a 2s.c o m try { out = new ObjectOutputStream(fos); out.writeObject(obj); out.flush(); } finally { out.close(); fos.close(); } } }