I have an app that has a large chunk of settings consisting of 7 string arrays, 3 strings and a date.Is it recommended to store it into a sqlite db or can I use the preference or is there any other alternative?
Asked
Active
Viewed 91 times
0
-
1Why not just create a simple (xml?) file in the application data path? – a sandwhich Jun 19 '12 at 03:00
-
Im new to android....can you give me some links with examples to this? – jaisonDavis Jun 19 '12 at 03:05
-
http://developer.android.com/reference/java/io/File.html http://www.anddev.org/write_to_and_read_from_a_file-t3173.html The forums link is rather helpful if I remember correctly. It guides you on how to create a private file, which I think is what you are wanting. – a sandwhich Jun 19 '12 at 03:09
-
That actually doesn't sound like *that much* data. How many bytes are we talking about in these strings? 10s? 1000s? I would just use the shared preferences if you just have 10 fairly short things to store. It really depends on how big your strings are and how many are in the arrays. – i_am_jorf Jun 19 '12 at 03:40
-
So its better to use shared prefs instead of a file? – jaisonDavis Jun 19 '12 at 03:44
-
I wouldn't say that. In some cases it is much easier to write the code if you just use the preferences stuff. I mean, the preferences stuff is backed by a file anyway. It really depends on how much data you need to store and how often you need to access it. And how you're using it in other ways. It's not black and white. – i_am_jorf Jun 19 '12 at 04:51
-
ok.Thanks.I'll go with preferences – jaisonDavis Jun 20 '12 at 17:27
1 Answers
1
Recommended storage for settings and preferences in android is Preferences, you can save StringArray into preference by converting it to Set first, then store into preferences, by method:
prefEditor.putStringSet("key", set);

jeet
- 29,001
- 6
- 52
- 53