-2

I would like to store and recall user's favorite links from string.xml how can I do this?

I would like clarify that the user only enter a name for favourite url, for example, sports it will be associated with the page that the user is currently viewing on my app (ex. 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>

in my activity

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
}

Edit: I found the solution here: Store a List or Set in SharedPreferences

Community
  • 1
  • 1
user1001635
  • 3,262
  • 3
  • 16
  • 17

1 Answers1

1

Have you read the examples here?

If you need to store something more complex than just simple preferecnes, you should probably just store the stuff into a database.

Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102
  • my problem is slightly different because I do not know the number of url to be retrieved and also their name, I can't find an example that retrieves a string array only string with constant name – user1001635 Nov 02 '11 at 17:09
  • Not sure if I fully understand your question, but I've modified my answer to try to address it. – Kurtis Nusbaum Nov 02 '11 at 17:16