added in version 24.1.0
belongs to Maven artifact


public class Preference
extends Object implements Comparable<Preference>

Known Direct Subclasses
Known Indirect Subclasses

Represents the basic Preference UI building block displayed by a PreferenceFragmentCompat in the form of a RecyclerView. This class provides data for the View to be displayed in the list and associates with a SharedPreferences to store/retrieve the preference data.

When specifying a preference hierarchy in XML, each element can point to a subclass of Preference, similar to the view hierarchy and layouts.

This class contains a key that will be used as the key into the SharedPreferences. It is up to the subclass to decide how to store the value.

Developer Guides

For information about building a settings UI with Preferences, read the Settings guide.


Nested classes

class Preference.BaseSavedState

A base class for managing the instance state of a Preference