On my android app I'm using a custom class, that extends from application, to share persistent data between activities and what I want to know is the best way to store that class ? With this I mean; what is the best storage option for my custom class so, if the user reboots or kills the app, I don't lose any information.
Asked
Active
Viewed 257 times
0
-
1shared prefrences does not clear until and unless you do so. Else database in android is a good option too. – Murtaza Khursheed Hussain Jan 12 '15 at 12:04
-
1Shared preferences is the way to go, for storing options http://developer.android.com/training/basics/data-storage/shared-preferences.html They are cleared on uninstall, or if the user manually clears it. – IAmGroot Jan 12 '15 at 12:04
-
What I want to store are not user options. Maybe a database is the best option. – Nuno Jan 12 '15 at 12:21
1 Answers
1
Your options:
- Parse the object to a JSON string and save it in shared prefrences. google-gson
- Serialize and save the object. example
- Use a SingleTon to make data accessible. example

Community
- 1
- 1

Robin Dijkhof
- 18,665
- 11
- 65
- 116