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?

Henry
  • 1,395
  • 1
  • 12
  • 31

0 Answers0