Iam在一個android應用程序中工作,其中我從JSON格式的服務器獲得響應。我想將鍵值對存儲在strings.xml中。它怎麼做? JSON響應如下。在Android中的strings.xml中編寫
{
"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"
}
]
}
strings.xml並不意味着存儲在運行時生成的數據。它用於存儲用於佈局的任何常量等。考慮使用SharedPreferences,平面文件或數據庫來存儲這些字符串。 –
User Array ArrayList/Array存儲這些值並使用它,在需要的地方。 – Aerrow
@VinaySShenoy感謝您的建議,現在請您告訴我如何使用共享偏好保存此響應? –