Reputation: 4991
I need a sugestion for my app. I need to save in app some arrays of Strings. How can I do this? Which is the best way for doing this?
Thanks in advance...
Upvotes: 1
Views: 612
Reputation: 40228
There are probably two different solutions:
SharedPreferences
SQLite
DatabaseYou can pick one depending on how many strings you want to save. SharedPreferences
is commonly used for storing a small amount of data and making it easy to access it. Databases should be used if you want to store a bigger amount of data.
Upvotes: 0
Reputation: 4794
If every String in your array is only a 1 or a 0, then you can build one large String of everything and put in a SharedPreference. When you fetch the saved value all you have to do is parse it character by character to get your 1s and 0s again.
Upvotes: 0
Reputation: 11775
If the string array is a constant thing, then you can define it in the resources
<string-array name="my_array">
<item>item1</item>
<item>item2</item>
</string-array>
You can grab it from the resources later like this
String[] myArray = getResources().getStringArray(R.array.my_array)
Upvotes: 3
Reputation: 15477
You can use SQLite Database or file in the sdcard to store the strings.It depends on how you need to use them.
Upvotes: 1