0

I have looked up a lot about the different data storage methods, and am trying to figure out at what point Android SharedPreferences is not right.

I realize the limitation of a string is quite colossal (~2B), so storing it isn't a problem memory-wise, I'm more curious about "Best Practice."

I will have somewhere between 5 and 15 "Updates" that I will have over the life of this app. I would like each phone to save these updates. An update will have a short title, and be anywhere from a sentence to two paragraphs.

I realize there is usually a concern of extensability, but there is no concern for that here. It is an app used yearly for 1 weekend.

I need no search or manipulation to these, just the ability to store them.

I could use GSON to store them all as a JSON object, but is that just too big of a string for preferences? Or is it fine because internal storage (as a CSV or something) or a database would be overkill?

dewyze
  • 979
  • 1
  • 7
  • 21

2 Answers2

7

So basically you are going to put up to 15 not-that-huge strings somewhere? Go for SharedPreferences then without a fear.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • Yeah, that's the plan. But I am somewhat new to Android Programming, and didn't want to commit an ugly storage sin like arrays in databases or something like that. – dewyze Jun 26 '13 at 19:44
  • Basically shared preferences data is kept in private XML file so it is not fastest option available, but in your case it is really not important factor anyway. Sure, you can go for DB if you want (just to find out how to do that - it's not that complex anyway), but there is no benefit from doing so in this particular case. – Marcin Orlowski Jun 26 '13 at 21:00
0

SharedPreferences is just an XML file which resides in the app's private directory.

You can view its content on an emulator or a rooted device.

Where are shared preferences stored?

Community
  • 1
  • 1
A.G.
  • 2,037
  • 4
  • 29
  • 40