3

I have an Array called Upvalthat has 16 Integer values that I would like to store in my SharedPreferences without creating individual ones for each, but SharedPrefernces won't allow Array's, what is the simplest way of doing this? The declaration looks something like this:

Integer[] UpVal = new Integer[16];

2 Answers 2

6

You can store it as a String by transforming it:

Arrays.toString(upVal)

To get it back and convert a String to an Integer array is trivial.

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

Comments

1

You can serialize an array to String using TextUtils.join(";", myInts) and the deserialize it back using something like TextUtils. SimpleStringSplitter or implement your own TextUtils.StringSplitter.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.