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
2 Answers
There is no way you can store an array as it is. Either you can convert it to JSON String and store it as a string. Or you can store each element of the array individually with an ID like this.
Comments
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.
1 Comment
OneCricketeer
Storing
JSONArray doesn't require any dependency