Changing value of R.String Programmatically

余生长醉 提交于 2019-12-01 04:32:57

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.

If you need to save small amounts of String information you should be using SharedPreferences that's exactly what it's for :)

There are many ways to finish your ideas. But, you cannot change your String resource, (as well as R.java resource), or layout resource,... and any other resource. You can do this by change resource to assets. this can read and write :)

You can get value from res/string value by this way.

String str = getResources().getString(R.string.<name_of_value>);

Now you can further use this value of this(str) String variable.
But according to me there is no way to set value of res/string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!