from what I can incur out of the SharedPreferences documentation, I can update a preference, add one or clear all preference values in a shared preference file.
But I want to completely clear everything inside a shared preference file, not just the values, but the preferences they refer to as well.
If you have a
SharedPreferences.Editorobject and you callclear(), does this not get you what you want? It will remove all preferences and if you callsharedPref.getAll()it should give you a map of size 0 [I just tested this].To remove one specific preference, call
editor.remove(pref), where pref is the preference name.PS: Don’t forget to commit your changes by calling commit() or apply() method on the editor. apply() is faster as it is asynchronous. commit() is synchronous but returns a boolean indicating if the commit succeeded.