Reputation: 1483
I am making an application which is saving the values in arrays
and I have 7 arrays like this. Now I want to save these values for future use although the application is restarted. I am confused between database
and sharedprefrences
. Pls tell me what I can use for this approach and why??
And if I use sharedpreferences
then is there any way to store multiple rows of data or I can use SQLite only?? Please do tell.. Thanx in advance...
Upvotes: 0
Views: 849
Reputation: 1699
These two are 2 of the methods for saving persistent data. There are both pros and cons. My opinion is that if you want to save a large amount of data I will go with the database. The preferences are more like saving states or valuable information that require a key-value pair. A simple example is saving the value of an EditText or how many times the user has logged in the application.
Although in your case the database might seem more appropriate, the implementation is a little time consuming and I don't know if it's worth it for your case. If there is a possibility of expanding the dataset that you wish to save then go with the database. It's up to you.
I hope this answer gave you a briefly overview.
Upvotes: 2
Reputation: 443
One way is discussed here: StackOverflow - How to Implement Persistent Storage in Android
Here's something that shows three different kinds of storage: Data Storage in Android
Upvotes: 1