android - 以编程方式更改 R.String 的值

标签 android android-2.3-gingerbread

您可以在 android 程序中以编程方式更改 R.string 的值吗?我需要提取一些 API 信息(例如电池状态、电池百分比、android 操作系统版本)并想将其保存为 R.string 值。我知道怎么读:

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

我还看过:Change value of R.string programically?但似乎只涉及改变语言,他最终以不同的方式做到了。任何人都可以伸出援手吗?我也看过这里:http://developer.android.com/guide/topics/resources/string-resource.html也没有找到任何帮助:(

最佳答案

您不能动态更改 strings.xml,因为它是编译资源。在 Android 中还有其他保存数据的机制,这里有一篇很好的文章介绍了这个主题:Data Storage .希望这会有所帮助。

关于android - 以编程方式更改 R.String 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9585029/

相关文章:

android - 2 ViewPager 在 Android 2.3 中不滚动

Android TextView 在 Android 2.3 中不会显示正确的行数

android - 无法在 Ubuntu 12.04 上连接 Android 版本 2.3.6 手机

android - 选项卡的自定义 Holo 主题

java - 如何在 RecyclerView 中显示 CardView(具有不同内容类型)

Android:获取系统默认 Activity 过渡动画

android - 在 Android calendarView 小部件上显示谷歌日历?

android - android studio 中奇怪的文件/库结构

android - SL4a 在后台识别语音

android - 我的 android ListView 不滚动