1

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
  • Convert it to JSON String and store it as a string Commented Oct 21, 2016 at 1:52
  • 3
    this should help stackoverflow.com/questions/7057845/… Commented Oct 21, 2016 at 2:00

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

Storing JSONArray doesn't require any dependency

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.