Reputation: 129
My android app saves an array of Objects to cache using serializable, but when updates are released, the array is completely deleted and users have to re-do all input. What is the solution to this? Thanks in advance
Upvotes: 0
Views: 72
Reputation: 12147
How did you store you serializable object to the cache? The package management system will keep the old data for an update installation of the app.
ObjectOutputStream objectOutputStream = null;
try {
objectOutputStream = new ObjectOutputStream(new FileOutputStream(
getCacheDir() + File.separator + "object"));
MyObject object = new MyObject();
object.setData(15);
object.setName("name");
objectOutputStream.writeObject(new MyObject());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (objectOutputStream != null) {
try {
objectOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Upvotes: 1
Reputation: 1501
Look into ActiveAndroid if you are fine with storing data on the device. Look into building out a restful API in the cloud if you want it to persist forever.
Upvotes: 0