Java tutorial
//package com.java2s; import android.content.Context; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static <T> void writeSerializedObject(Context context, String fileName, T objectToWrite) throws IOException { FileOutputStream fileOut = context.openFileOutput(fileName, Context.MODE_PRIVATE); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(objectToWrite); out.close(); fileOut.close(); } }