Reputation: 61
My preferences.xml and My Class in MainActivity.
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:key="@string/key"
android:title="@string/title_preferences"
android:summary="@string/sub_title_preferences"
android:dialogTitle="@string/popup_preferences" />
My Class
SharedPreferences preferences = getApplicationContext().getSharedPreferences(getString(R.string.key),0);
SharedPreferences.Editor edit = preferences.edit();
public String getfeed() {
String sh = preferences.getString(getString(R.string.key), "");
return sh;
}
public void setfeed(String rssfeed) {
edit.putString(getString(R.string.key), rssfeed);
edit.commit();
OnStart()
url = preferences.getfeed();
But is not updating the link typed.
Upvotes: 0
Views: 59
Reputation: 15
PreferenceScreen is connected to default shared preference. Any change will be automatically saved to it.
To retrieve this value, or modify from any other point of the app you can call the shared preference as
SharedPreferences preferences = getApplicationContext().getDefaultSharedPreference();
Just change this line in your code and everything will work perfectly.
Upvotes: 0