How can I store an Integer array in SharedPreferences in Android?

I have an Array with a name Upvalthat has 16 Integer values ​​that I would like to store in my SharedPreferences without creating separate ones for each, but SharedPrefernces will not allow Array, what is the easiest way to do this? The ad looks something like this:

Integer[] UpVal = new Integer[16];
+3
source share
2 answers

You can save it as a string by changing it:

Arrays.toString(upVal)

To return it and convert String to an Integer array is trivial.

+6
source

String TextUtils.join( ";", myInts) - TextUtils. SimpleStringSplitter TextUtils.StringSplitter.

+1

All Articles