Android examples for App:Cache
read Cache from Context
//package com.book2s; import android.content.Context; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { public static Object readCache(Context context, String key) { File data = context.getFileStreamPath(key); if (!data.exists()) { return null; }/*from w w w. ja va 2s.c o m*/ FileInputStream fis = null; ObjectInputStream ois = null; try { fis = context.openFileInput(key); ois = new ObjectInputStream(fis); try { return ois.readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } return null; } }