What is the best way to save several strings on android? I thought that the best way was SQLite, but in this case when I close my app the data will be save? When I open the app again the data will be there? Or should I use txt files to save it and restore it?
-
1Yes, SQLite will save your data. That's kind of the point ;) – John Carter Aug 14 '12 at 02:07
-
From where are you getting these strings? Server? User input? – iTurki Aug 14 '12 at 02:09
1 Answers
It depends on what you are trying to do with the file. You have several options when you are saving data: internal storage, external storage, caching, SQLite database, or networking. If you are just saving a couple Strings
I think that creating a database is overkill. I would look at saving the files to internal storage. You can write the Strings
to a file then retrieve that file when you restart the app.
You don't want to make things more complicated than they need to be. Keep it simple. If you are saving a couple KB worth of data, use a file. If you are getting into MB worth of data, and need to query specific data sets, then look at a database. You have to remember that databases take a lot of time and resources, not only to set up, but to maintain.
Here is the Android document that outlines the different ways to save data to a device: http://developer.android.com/guide/topics/data/data-storage.html
This should really help you understand what is going to be best for you.

- 23,275
- 22
- 95
- 156