0

I'm relatively new to Android but have programmed in other languages for many years. I'm finding the XML resource files in Android useful and am wondering if I can modify a resource file in my program?

One of the things my current app does is initialize a couple of spinners with a handful of values each. I realize that I can simply set up a string array within strings.xml to identify the exact values that each spinner should get but I want to go a step beyond that.

I've created a couple of enums, one for each spinner, and each enum includes the various values that the spinner can have, plus supporting information that isn't needed in the spinner but is useful in other places. I always want my spinner values to come from the enum.

I think I'd like to write the string arrays for strings.xml programmatically in my app every time the app begins executing so that it's always getting a fresh copy of whatever values are in the enum at that moment.

Is that possible? Or are the resource files immutable once the app begins running?

If it is possible to write strings.xml programmatically, is it a bad idea in any way?

2
  • stackoverflow.com/questions/9674925/…, refer this duplicate Commented Jul 20, 2018 at 4:07
  • Okay, thanks. Apparently I can NOT modify anything in the res folder at runtime. That's useful to know. Commented Jul 20, 2018 at 16:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.