Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing value of R.String Programmatically

Can you change the values of a R.string programmatically in an android program? I need to pull some API information (for example battery state, battery percentage, android os version) and would like to save it a R.string value. I know how to read it:

 String helloValue= getResources().getString(R.string.hello);

I've also looked at: Change value of R.string programically? but it seems that only involves changing language and he ended up doing it a different way. Can anyone lend a hand please? I've also looked here: http://developer.android.com/guide/topics/resources/string-resource.html and found nothing to help out either :(

like image 985
Falcon165o Avatar asked Mar 06 '12 13:03

Falcon165o


1 Answers

You can't change strings.xml dynamically since it's a compiled resource. There are other mechanisms for saving data in Android, here's a nice post that covers this topic: Data Storage. Hope this helps.

like image 114
Egor Avatar answered Oct 13 '22 01:10

Egor