是否有可能改变加在RES / strings.xml中的android的字符串值,在运行时/或code [英] Is it possible to change value of string added in res/strings.xml in android at run time/ or by code

查看:268
本文介绍了是否有可能改变加在RES / strings.xml中的android的字符串值,在运行时/或code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的机器人,我知道我们可以利用的资源字符串存储的值,但有可能在运行时改变这些值。比如我添加了两个新的资源要素用户名和密码,我想在运行时更改此值。或者是有什么替代的方法来存储值。

I am very new to android, I know we can use resource strings to store values, but is it possible to change those values at run time. for example I added two new resource elements username and password, i want to change this values at run time. or is there any alternate way to store values.

很多的感谢!

推荐答案

字符串资源是绝对静态的定义,你无法改变自己的价值观。 使用共享preference 这是存储你的数据,你可以改变,更新或做任何适合您的需要。

String resources are absolutely static defined, you can't change their values. Use SharedPreference which is to store your data and you can change, update or do whatever to suit your needs.

下面用共享preference 示例:<一href="http://stackoverflow.com/questions/3624280/how-to-use-shared$p$pferences-in-android-to-store-fetch-and-edit-values">How使用共享preferences在Android的存储,读取和编辑值

这篇关于是否有可能改变加在RES / strings.xml中的android的字符串值,在运行时/或code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆