Android – Change value in strings.xml

android

So inside strings.xml I have a string called change_bg and I'd like to change it's value according to click events.

I know that in order to get the value you use

changeBG=getString(R.string.change_bg);

But I don't know how to SET the value of
R.string.change_bg

Please let me know how.

Thanks in advance!
Dvir

Best Answer

You can't change resource files during runtime. Strings are hard-coded in the string.xml file and hence can't be changed during runtime. Instead of trying to edit your strings.xml file, just use SharedPreferences to store the user's preferences if that's what you're trying.