Reputation: 89
Does anyone know how I could reset all of the settings in my app? Imagine I have some checkboxes and list preferences. How could I reset everything to how it was just after the app was installed - the checkbox preferences are checked/unchecked, the list preferences reset to the default value)?
Thanks
Upvotes: 1
Views: 2026
Reputation: 522
Ensure you have default values set for each pref in the XML file. E.g.:
android:defaultValue="3600000"/>
Then you can do this in the code:
// Log.d(TAG, "Setting default preference values.");
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
Upvotes: 0
Reputation: 484
SharedPreferences prefs = Context.getSharedPreferences("FileName", Context.MODE_PRIVATE);
Editor editor = prefs.edit();
editor.clear();
editor.commit();
Just call editor.clear();
to reset it.
Upvotes: 3