Java tutorial
//package com.java2s; import android.util.Log; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { @SuppressWarnings("unused") public static Object readObject(String path) { File file = new File(path); return readObject(file); } public static Object readObject(File file) { Object obj = null; if (file != null && file.exists()) { FileInputStream fileInputStream = null; ObjectInputStream objectInputStream = null; try { fileInputStream = new FileInputStream(file); objectInputStream = new ObjectInputStream(fileInputStream); obj = objectInputStream.readObject(); } catch (IOException | ClassNotFoundException e) { Log.d("readObject", e.getMessage()); } finally { try { if (objectInputStream != null) { objectInputStream.close(); } if (fileInputStream != null) { fileInputStream.close(); } } catch (IOException e) { Log.d("readObject", e.getMessage()); } } } return obj; } }