• 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
Feb 16, 2011
2
0
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");
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones