Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static void writeDataFile(String filename, Context context, Object object) { File file = new File(context.getDir("data", 0), filename); try { ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(file, false)); outputStream.writeObject(object); outputStream.flush(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } }