我想从string.xml存储和调用用户最喜欢的链接,我该怎么做?
我想澄清一下,用户只输入收藏网址的名称,例如,体育活动它将与用户当前在我的应用上查看的网页相关联(例如www.sport.com)
my string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyApp</string>
<string-array name="Name_Fav"></string-array>
//Here I would like to store the names of url favorites
//<item >Sport</item>
<string-array name="Url_Fav"></string-array>
//Here I would like to store full url
//<item >www.sport.com</item>
</resources>
在我的活动中
public void onClick(View v) {
String[] name_url = //Items retrieved from Name_Fav (sport)
String[] url_fav = //items retrieved from Url_FAv (www.sport.com)
//now here I would like to put and retrieve the data from the resource file
}
编辑:我在这里找到了解决方案: Store a List or Set in SharedPreferences