-1

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?

AnujAroshA
  • 4,623
  • 8
  • 56
  • 99
Lino
  • 295
  • 1
  • 5
  • 19

1 Answers1

3

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.

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156