1

I have a res/values String-array that I would like users to be able to add new elements to via a form. I saw a post from 2011 that asked this question (How to update arrays in res/values/array.xml by code?) however, the answer stated that resource arrays are read-only at run time. I was wondering if anything has changed since 2011 that would allow users the ability to update the resource array (add new strings to it).

1 Answer 1

2

Unfortunately resource values are still immutable. They are generated when your project is compiled and overriden on every compilation. There is a corresponding warning here in the documentation: https://developer.android.com/guide/topics/resources/accessing-resources.html

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

2 Comments

Thank you Dr. Nedolya - any ideas for a work around? I know you could do it with a db connection - but I kind of wanted to keep it stand-alone
@MichaelCarolan You can also try to store your array in SharedPreferences, like in this question: stackoverflow.com/questions/7361627/… Another option is to store your data in standalone file which would be placed in your app's private directory.

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.