0

我正在开发一个 android 应用程序,在该应用程序中我从服务器以 JSON 格式获得响应。我想将键值对存储在 strings.xml 中。怎么做?JSON 响应如下。

 {
"ResourceStrings": [
    {
        "Key": "AccountNumber",
        "Value": "Account Number"
    },
    {
        "Key": "AccountPassword",
        "Value": "Account Password"
    },
    {
        "Key": "AccountSettings",
        "Value": "Account"
    },
    {
        "Key": "AccountSettings.Load.InfoMessage",
        "Value": "The Account Number and Password only needs to be set one time.  \r\n\r\nIf you do not know the Account information please contact you system administrator or your DataXchange reseller."
    },
    {
        "Key": "Add",
        "Value": "Setup"
    },
    {
        "Key": "AddandModifytheScreens",
        "Value": "Add and Modify the Screens"
    },
    {
        "Key": "AddButton",
        "Value": "Add"
    },
    {
        "Key": "AddButtonClick.InfoMessage",
        "Value": "Enter the new information and press the Enter button to save the changes.\r\n\r\nOr, press the Cancel button to discard the new information."
    },
    {
        "Key": "AddCommunication",
        "Value": "Add Communication"
    },
    {
        "Key": "AdvancedSettings",
        "Value": "Advanced Settings"
    }
]
}
4

2 回答 2

7

您不能在运行时的 strings.xml 中写入任何内容。相反,您可以写入共享首选项、数据库或内部/外部存储中的文件。所有这些方式都列在Android 开发者网站上

于 2012-10-01T12:14:04.787 回答
0

正如@ingsaurabh所说

无法以编程方式在 string.xml 中编写任何内容,但可以通过 SharedPreferences http://developer.android.com/guide/topics/data/data-storage.html#pref来完成。

但是有更多的价值才能更好地维护数据库

于 2012-10-01T12:16:15.273 回答