Note that there are some explanatory texts on larger screens.

plurals
  1. POResetting preferences when using PreferenceScreen
    primarykey
    data
    text
    <p>I am loading a PreferenceScreen from an xml file to use as the screen to configure a new event so I'm attempting to clear and reset the values of the SharedPreference this activity is using. The problem I'm encountering is that when attempting to move to using a named preference manager, it seems the preference gets cleared but when I select an EditTextPreference element, the old data is still the default entered text on the popup.</p> <p>In my onCreate method I'm attempting to initialize the preferences, clear them, then set to default values. My understanding from the dev resources were that there's no way to clear/reset in one step..</p> <pre><code>private static final String PREFNAME = "newmeetingactivity.preferences"; //load preferences and set name addPreferencesFromResource(R.layout.newmeeting_preferences); getPreferenceManager().setSharedPreferencesName(PREFNAME); getPreferenceManager().setSharedPreferencesMode(MODE_PRIVATE); //Clear the preferences _sharedPreferences = getPreferenceManager().getSharedPreferences(); SharedPreferences.Editor ed = _sharedPreferences.edit(); ed.clear(); ed.commit(); //Load default preferences from file again PreferenceManager.setDefaultValues(this, _sharedPreferences.toString() , MODE_PRIVATE, R.layout.newmeeting_preferences, true); </code></pre> <p>Edit: To try to better explain what I'm attempting to do (in case my approach is way off): I need to clear shared preferences used on a given activity while not interfering with the settings from other activities (as they should persist indefinitely).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload