• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Retrieving preference in a url string

watsonink

Lurker
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...
 
If you don't know how to get a string from a preference, here goes:
Code:
PreferenceManager.getDefaultSharedPreferences(this).getString("PreferenceKey", "DefaultReturnValueIfPreferenceKeyIsNotFound");

Together this would be something like this:
Code:
String feedUrl = "http://www.yourwebsite.com/android/objects/XML/AND.php?ID=" + PreferenceManager.getDefaultSharedPreferences(this).getString("PreferenceKey", "DefaultReturnValueIfPreferenceKeyIsNotFound");
 
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"
 
Back
Top Bottom