@SuppressWarnings("unchecked")
public List<Map<String, Object>> fetch(String name)
{
List<Map<String, Object>> data = null;
SharedPreferences preferences = getSharedPreferences("base64",Context.MODE_PRIVATE);
String dataBase64 = preferences.getString(name, "");
if (dataBase64 != "") {
byte[] base64 = Base64.decode(dataBase64.getBytes(),Base64.DEFAULT);
ByteArrayInputStream bais = new ByteArrayInputStream(base64);
try {
ObjectInputStream bis = new ObjectInputStream(bais);
try {
data = (List<Map<String, Object>>) bis.readObject();
} catch (ClassNotFoundException e) {
}
} catch (StreamCorruptedException e) {
} catch (IOException e) {
}
}
return data;
}
public void save(List<Map<String, Object>> data,String name)
{
SharedPreferences preferences = getSharedPreferences("base64",Context.MODE_PRIVATE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(data);
String dataBase64 = new String(Base64.encodeToString(baos.toByteArray(),Base64.DEFAULT));
Editor editor = preferences.edit();
editor.putString(name, dataBase64);
editor.commit();
} catch (IOException e) {
}
}