Java tutorial
//package com.java2s; import android.content.Context; import android.util.Base64; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.ObjectInputStream; public class Main { public static Object toObject(String base64str) { Object obj = null; try { obj = toObject(Base64.decode(base64str, Base64.DEFAULT)); } catch (Exception e) { e.printStackTrace(); } return obj; } public static Object toObject(byte[] bytes) { Object obj = null; try { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bis); obj = ois.readObject(); ois.close(); bis.close(); } catch (Exception ex) { ex.printStackTrace(); } return obj; } public static Object readObject(Context context, String filename) { FileInputStream in = null; ObjectInputStream oin = null; Object data = null; try { in = context.openFileInput(filename + ".odb"); oin = new ObjectInputStream(in); data = oin.readObject(); oin.close(); in.close(); } catch (Exception e) { e.printStackTrace(); } return data; } }