Search code examples
androidpreferences

How to access all the children of a PreferenceScreen?


I'm trying to programmatically uncheck all the CheckBoxPreference children of a PreferenceScreen in my app. How can I do that?


Solution

  • Found a simpler way - sufficient for my use case - which is to clear the preferences. This can be done by a static method provided a context is passed to it:

    PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();