1. Are you ready for the Galaxy S20? Here is everything we know so far!

Apps Retrieving preference in a url string

Discussion in 'Android Development' started by watsonink, Feb 16, 2011.

  1. watsonink

    watsonink Lurker
    Thread Starter

    final SharedPreferences prefs=PreferenceManager
    .getDefaultSharedPreferences(this);

    static String feedUrl = String.format("http://www.yourwebsite.com/android/objects/XML/AND.php?ID=%d", 22);


    the "22" should be a int variable from the preferences.

    I am saving the preferences correctly but can't concatenate the int with the below string.

    Any help would be appreciated...
     

    Advertisement

  2. miXer

    miXer Android Enthusiast

    If you don't know how to get a string from a preference, here goes:
    Code (Text):
    1. PreferenceManager.getDefaultSharedPreferences(this).getString("PreferenceKey", "DefaultReturnValueIfPreferenceKeyIsNotFound");
    Together this would be something like this:
    Code (Text):
    1. String feedUrl = "http://www.yourwebsite.com/android/objects/XML/AND.php?ID=" + PreferenceManager.getDefaultSharedPreferences(this).getString("PreferenceKey", "DefaultReturnValueIfPreferenceKeyIsNotFound");
     
  3. watsonink

    watsonink Lurker
    Thread Starter

    Thanks for responding miXer...

    My parser is a "static' string, is there a way to concatenate the preference into the string while keeping it as "static".

    I did try to replace the string you posted and it error'd stating "'(this)' can't be static"
     
Loading...
Similar Threads - Retrieving preference url
  1. Papamalo
    Replies:
    0
    Views:
    121
  2. Jasmin74
    Replies:
    12
    Views:
    763
  3. Erock89
    Replies:
    8
    Views:
    4,537
  4. bjharrell
    Replies:
    3
    Views:
    521
  5. Bhavya Panchotia
    Replies:
    2
    Views:
    800
  6. nopeda
    Replies:
    0
    Views:
    181
  7. Dave3d
    Replies:
    14
    Views:
    3,234
  8. Murtholemu
    Replies:
    0
    Views:
    340
  9. MVolkoff
    Replies:
    4
    Views:
    53,410
  10. galaxynotace
    Replies:
    14
    Views:
    7,773

Share This Page

Loading...