added in version 24.1.0
belongs to Maven artifact


public class PreferenceManager
extends Object


Used to help create Preference hierarchies from activities or XML.

In most cases, clients should use addPreferencesFromResource(int), or addPreferencesFromResource(int).


Nested classes

interface PreferenceManager.OnDisplayPreferenceDialogListener

Interface definition for a class that will be called when a Preference requests to display a dialog. 

interface PreferenceManager.OnNavigateToScreenListener

Interface definition for a class that will be called when a PreferenceScreen requests navigation. 

interface PreferenceManager.OnPreferenceTreeClickListener

Interface definition for a callback to be invoked when a Preference in the hierarchy rooted at this PreferenceScreen is clicked. 

class PreferenceManager.PreferenceComparisonCallback

Callback class to be used by the RecyclerView.Adapter associated with the PreferenceScreen, used to determine when two Preference objects are semantically and visually the same. 

class PreferenceManager.SimplePreferenceComparisonCallback

A basic implementation of PreferenceManager.PreferenceComparisonCallback suitable for use with the default Preference classes. 



Public methods

PreferenceScreen createPreferenceScreen(Context context)
Preference findPreference(CharSequence key)

Finds a Preference based on its key.

Context getContext()

Returns the context.

static SharedPreferences getDefaultSharedPreferences(Context context)

Gets a SharedPreferences instance that points to the default file that is used by the preference framework in the given context.

PreferenceManager.OnDisplayPreferenceDialogListener getOnDisplayPreferenceDialogListener()
PreferenceManager.OnNavigateToScreenListener getOnNavigateToScreenListener()

Returns the PreferenceManager.OnNavigateToScreenListener, if one has been set.

PreferenceManager.OnPreferenceTreeClickListener getOnPreferenceTreeClickListener()