I have an array integer in android studio like this { 0 , 0 , 0 , 1 , 1 , 0 , 1} how can I store and recall it in shared preferences
Asked
Active
Viewed 1,346 times
1
-
Convert it to JSON String and store it as a string – priyank Oct 21 '16 at 01:52
-
3this should help http://stackoverflow.com/questions/7057845/save-arraylist-to-sharedpreferences – Linh Oct 21 '16 at 02:00
2 Answers
0
Build a string out of it. Preferably using StringBuilder
.
And, when reading, just split()
on commas and then user Integer.parseInt()
on all elements of the array.
Should be faster than the json route and does not require any extra dependency.

KarolDepka
- 8,318
- 10
- 45
- 58