Reputation:
I am working on an android application that will randomly choose a activity for people to do from an array list. I want this list to be edited by the user of the application by adding or removing activities from the list. I would like the list to be loaded when the application is opened and saved when paused, closed, or destroyed.
I cannot figure out how to store the array list an load it. I have tried to understand posts in the past about this topic but cannot make sense of how to implement them.
I you can help, it would be greatly appreciated.
Upvotes: 0
Views: 39
Reputation: 2149
You have some alternatives:
1) Use a local database (I suggest greendao for the great performance). Here's the oficial page
That way like in a conventional database you store (in the OnPause method) the data and query it the next time the user opens the app.
2) Use serialization (its convenient for small amount of data), as the previous one in the onPause method you serialize the object and deserialize it when the users open the app. Here's a tutorial about it
Upvotes: 1