# EditTextPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:preference-v7:28.0.0-alpha1  
Summary:[Inherited XML Attrs](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#inhattrs)\|[Inherited Constants](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#inhconstants)\|[Ctors](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)  

# EditTextPreference

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
EditTextPreference
`  
`


``


``

extends `[DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)`


``


`

|---|---|---|--------------------------------------------------|
| java.lang.Object                                          ||||
| ↳ | [android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) |||
|   | ↳ | [android.support.v7.preference.DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference) ||
|   |   | ↳ | android.support.v7.preference.EditTextPreference |

<br />

*** ** * ** ***

A[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)that allows for string input.

It is a subclass of[DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)and shows the[EditText](https://developer.android.com/reference/android/widget/EditText.html)in a dialog.

This preference will store a string into the SharedPreferences.

## Summary

| ### Inherited XML attributes |
|------------------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---| | [`Preference_android_iconSpaceReserved`](https://developer.android.com/reference/android/support/v7/preference/Preference#attr_Preference_android_iconSpaceReserved) |   | | [`Preference_android_singleLineTitle`](https://developer.android.com/reference/android/support/v7/preference/Preference#attr_Preference_android_singleLineTitle)     |   | ||

|                                                                                                                                                                                                                                                                                                                                                                                                                                              ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [DEFAULT_ORDER](https://developer.android.com/reference/android/support/v7/preference/Preference#DEFAULT_ORDER) Specify for[setOrder(int)](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))if a specific order is not required. | |

|                                                                                                                                                                                                        ### Public constructors                                                                                                                                                                                                         ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#EditTextPreference(android.content.Context, android.util.AttributeSet, int, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs, int defStyleAttr, int defStyleRes) ` |
| ` `[EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#EditTextPreference(android.content.Context, android.util.AttributeSet, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs, int defStyleAttr) `                       |
| ` `[EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#EditTextPreference(android.content.Context, android.util.AttributeSet))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs) `                                              |
| ` `[EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#EditTextPreference(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) `                                                                                                                                                                         |

|                                                                                                                                   ### Public methods                                                                                                                                   ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` String`  | ` `[getText](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#getText())`() ` Gets the text from the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html).                           |
| ` void`    | ` `[setText](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#setText(java.lang.String))`(String text) ` Saves the text to the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). |
| ` boolean` | ` `[shouldDisableDependents](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#shouldDisableDependents())`() ` Checks whether this preference's dependents should currently be disabled.                                            |

|                                                                                                                                                                                                                                                                                           ### Protected methods                                                                                                                                                                                                                                                                                           ||
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` Object`                                                                           | ` `[onGetDefaultValue](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#onGetDefaultValue(android.content.res.TypedArray, int))`(`[TypedArray](https://developer.android.com/reference/android/content/res/TypedArray.html)` a, int index) ` Called when a Preference is being inflated and the default value attribute needs to be read.                                                                                                                                    |
| ` void`                                                                             | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#onRestoreInstanceState(android.os.Parcelable))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()). |
| ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#onSaveInstanceState())`() ` Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state.                                                                                                                                                                                                                    |
| ` void`                                                                             | ` `[onSetInitialValue](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#onSetInitialValue(boolean, java.lang.Object))`(boolean restoreValue, Object defaultValue) ` Implement this to set the initial value of the Preference.                                                                                                                                                                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)From class` `[android.support.v7.preference.DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)` ` |------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html) | ` `[getDialogIcon](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogIcon())`() ` Returns the icon to be shown on subsequent dialogs.                                                                                                                                                                      | | ` int`                                                                                         | ` `[getDialogLayoutResource](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogLayoutResource())`() ` Returns the layout resource that is used as the content View for subsequent dialogs.                                                                                                                 | | ` CharSequence`                                                                                | ` `[getDialogMessage](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogMessage())`() ` Returns the message to be shown on subsequent dialogs.                                                                                                                                                             | | ` CharSequence`                                                                                | ` `[getDialogTitle](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogTitle())`() ` Returns the title to be shown on subsequent dialogs.                                                                                                                                                                   | | ` CharSequence`                                                                                | ` `[getNegativeButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getNegativeButtonText())`() ` Returns the text of the negative button to be shown on subsequent dialogs.                                                                                                                               | | ` CharSequence`                                                                                | ` `[getPositiveButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getPositiveButtonText())`() ` Returns the text of the positive button to be shown on subsequent dialogs.                                                                                                                               | | ` void`                                                                                        | ` `[onClick](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#onClick())`() ` Processes a click on the preference.                                                                                                                                                                                                 | | ` void`                                                                                        | ` `[setDialogIcon](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogIcon(int))`(int dialogIconRes) ` Sets the icon (resource ID) of the dialog.                                                                                                                                                           | | ` void`                                                                                        | ` `[setDialogIcon](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` dialogIcon) ` Sets the icon of the dialog.                                                   | | ` void`                                                                                        | ` `[setDialogLayoutResource](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogLayoutResource(int))`(int dialogLayoutResId) ` Sets the layout resource that is inflated as the[View](https://developer.android.com/reference/android/view/View.html)to be shown as the content View of subsequent dialogs. | | ` void`                                                                                        | ` `[setDialogMessage](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogMessage(java.lang.CharSequence))`(CharSequence dialogMessage) ` Sets the message of the dialog.                                                                                                                                    | | ` void`                                                                                        | ` `[setDialogMessage](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogMessage(int))`(int dialogMessageResId) `                                                                                                                                                                                           | | ` void`                                                                                        | ` `[setDialogTitle](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogTitle(int))`(int dialogTitleResId) `                                                                                                                                                                                                 | | ` void`                                                                                        | ` `[setDialogTitle](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogTitle(java.lang.CharSequence))`(CharSequence dialogTitle) ` Sets the title of the dialog.                                                                                                                                            | | ` void`                                                                                        | ` `[setNegativeButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setNegativeButtonText(java.lang.CharSequence))`(CharSequence negativeButtonText) ` Sets the text of the negative button of the dialog.                                                                                                 | | ` void`                                                                                        | ` `[setNegativeButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setNegativeButtonText(int))`(int negativeButtonTextResId) `                                                                                                                                                                            | | ` void`                                                                                        | ` `[setPositiveButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setPositiveButtonText(int))`(int positiveButtonTextResId) `                                                                                                                                                                            | | ` void`                                                                                        | ` `[setPositiveButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setPositiveButtonText(java.lang.CharSequence))`(CharSequence positiveButtonText) ` Sets the text of the positive button of the dialog.                                                                                                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |---------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean`                                                                                                                                              | ` `[callChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#callChangeListener(java.lang.Object))`(Object newValue) ` Call this method after the user changes the preference, but before the internal state is set.                                                                                                                                                                                                                                                                                                                                  | | ` int`                                                                                                                                                  | ` `[compareTo](https://developer.android.com/reference/android/support/v7/preference/Preference#compareTo(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` another) ` Compares Preference objects based on order (if set), otherwise alphabetically on the titles.                                                                                                                                                                                                                                    | | ` `[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)                                                       | ` `[findPreferenceInHierarchy](https://developer.android.com/reference/android/support/v7/preference/Preference#findPreferenceInHierarchy(java.lang.String))`(String key) ` Finds a Preference in this hierarchy (the whole thing, even above/below your[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)screen break) with the given key.                                                                                                                                                                                               | | ` `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                      | ` `[getContext](https://developer.android.com/reference/android/support/v7/preference/Preference#getContext())`() ` Returns the[Context](https://developer.android.com/reference/android/content/Context.html)of this Preference.                                                                                                                                                                                                                                                                                                                                                                 | | ` String`                                                                                                                                               | ` `[getDependency](https://developer.android.com/reference/android/support/v7/preference/Preference#getDependency())`() ` Returns the key of the dependency on this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                             | ` `[getExtras](https://developer.android.com/reference/android/support/v7/preference/Preference#getExtras())`() ` Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.                                                                                                                                                                                                                                                                                                                                                            | | ` String`                                                                                                                                               | ` `[getFragment](https://developer.android.com/reference/android/support/v7/preference/Preference#getFragment())`() ` Return the fragment class name associated with this Preference.                                                                                                                                                                                                                                                                                                                                                                                                             | | ` `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)                                                          | ` `[getIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#getIcon())`() ` Returns the icon of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` `[Intent](https://developer.android.com/reference/android/content/Intent.html)                                                                        | ` `[getIntent](https://developer.android.com/reference/android/support/v7/preference/Preference#getIntent())`() ` Return the[Intent](https://developer.android.com/reference/android/content/Intent.html)associated with this Preference.                                                                                                                                                                                                                                                                                                                                                         | | ` String`                                                                                                                                               | ` `[getKey](https://developer.android.com/reference/android/support/v7/preference/Preference#getKey())`() ` Gets the key for this Preference, which is also the key used for storing values into[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore).                                                                                                                                                                            | | ` final int`                                                                                                                                            | ` `[getLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#getLayoutResource())`() ` Gets the layout resource that will be shown as the[View](https://developer.android.com/reference/android/view/View.html)for this Preference.                                                                                                                                                                                                                                                                                                                    | | ` `[Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener) | ` `[getOnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#getOnPreferenceChangeListener())`() ` Returns the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).                                                                                                                                                                                                                                                                                                        | | ` `[Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)   | ` `[getOnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference#getOnPreferenceClickListener())`() ` Returns the callback to be invoked when this Preference is clicked.                                                                                                                                                                                                                                                                                                                                                                       | | ` int`                                                                                                                                                  | ` `[getOrder](https://developer.android.com/reference/android/support/v7/preference/Preference#getOrder())`() ` Gets the order of this Preference with respect to other Preference objects on the same level.                                                                                                                                                                                                                                                                                                                                                                                     | | ` `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)                                             | ` `[getParent](https://developer.android.com/reference/android/support/v7/preference/Preference#getParent())`() ` Returns the[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)which is this Preference assigned to or null if this preference is not assigned to any group or is a root Preference.                                                                                                                                                                                                                                        | | ` boolean`                                                                                                                                              | ` `[getPersistedBoolean](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedBoolean(boolean))`(boolean defaultReturnValue) ` Attempts to get a persisted[Boolean](https://developer.android.com/reference/java/lang/Boolean)if this Preference is persistent.                                                                                                                                                                                                                                                                                           | | ` float`                                                                                                                                                | ` `[getPersistedFloat](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedFloat(float))`(float defaultReturnValue) ` Attempts to get a persisted[Float](https://developer.android.com/reference/java/lang/Float)if this Preference is persistent.                                                                                                                                                                                                                                                                                                       | | ` int`                                                                                                                                                  | ` `[getPersistedInt](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedInt(int))`(int defaultReturnValue) ` Attempts to get a persisted[Integer](https://developer.android.com/reference/java/lang/Integer)if this Preference is persistent.                                                                                                                                                                                                                                                                                                           | | ` long`                                                                                                                                                 | ` `[getPersistedLong](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedLong(long))`(long defaultReturnValue) ` Attempts to get a persisted[Long](https://developer.android.com/reference/java/lang/Long)if this Preference is persistent.                                                                                                                                                                                                                                                                                                             | | ` String`                                                                                                                                               | ` `[getPersistedString](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedString(java.lang.String))`(String defaultReturnValue) ` Attempts to get a persisted set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                         | | ` Set<String>`                                                                                                                                          | ` `[getPersistedStringSet](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedStringSet(java.util.Set<java.lang.String>))`(Set<String> defaultReturnValue) ` Attempts to get a persisted set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                               | | ` `[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)                                     | ` `[getPreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/Preference#getPreferenceDataStore())`() ` Returns[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)used by this Preference.                                                                                                                                                                                                                                                                                                       | | ` `[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)                                         | ` `[getPreferenceManager](https://developer.android.com/reference/android/support/v7/preference/Preference#getPreferenceManager())`() ` Gets the[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)that manages this Preference object's tree.                                                                                                                                                                                                                                                                                           | | ` `[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)                                                  | ` `[getSharedPreferences](https://developer.android.com/reference/android/support/v7/preference/Preference#getSharedPreferences())`() ` Returns the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)where this Preference can read its value(s).                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                                                              | ` `[getShouldDisableView](https://developer.android.com/reference/android/support/v7/preference/Preference#getShouldDisableView())`() ` Checks whether this Preference should disable its view when it's action is disabled.                                                                                                                                                                                                                                                                                                                                                                      | | ` CharSequence`                                                                                                                                         | ` `[getSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#getSummary())`() ` Returns the summary of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` CharSequence`                                                                                                                                         | ` `[getTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#getTitle())`() ` Returns the title of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` final int`                                                                                                                                            | ` `[getWidgetLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#getWidgetLayoutResource())`() ` Gets the layout resource for the controllable widget portion of this Preference.                                                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[hasKey](https://developer.android.com/reference/android/support/v7/preference/Preference#hasKey())`() ` Checks whether this Preference has a valid key.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                              | ` `[isEnabled](https://developer.android.com/reference/android/support/v7/preference/Preference#isEnabled())`() ` Checks whether this Preference should be enabled in the list.                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` boolean`                                                                                                                                              | ` `[isIconSpaceReserved](https://developer.android.com/reference/android/support/v7/preference/Preference#isIconSpaceReserved())`() ` Returns whether the space of this preference icon view is reserved.                                                                                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                                                                              | ` `[isPersistent](https://developer.android.com/reference/android/support/v7/preference/Preference#isPersistent())`() ` Checks whether this Preference is persistent.                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` boolean`                                                                                                                                              | ` `[isSelectable](https://developer.android.com/reference/android/support/v7/preference/Preference#isSelectable())`() ` Checks whether this Preference should be selectable in the list.                                                                                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                                                              | ` `[isSingleLineTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#isSingleLineTitle())`() ` Gets whether the title of this preference is constrained to a single line.                                                                                                                                                                                                                                                                                                                                                                                      | | ` final boolean`                                                                                                                                        | ` `[isVisible](https://developer.android.com/reference/android/support/v7/preference/Preference#isVisible())`() ` Checks whether this preference should be visible to the user in the list.                                                                                                                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[notifyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyChanged())`() ` Should be called when the data of this[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)has changed.                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                 | ` `[notifyDependencyChange](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyDependencyChange(boolean))`(boolean disableDependents) ` Notifies any listening dependents of a change that affects the dependency.                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[notifyHierarchyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyHierarchyChanged())`() ` Should be called when a Preference has been added/removed from this group, or the ordering should be re-evaluated.                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[onAttached](https://developer.android.com/reference/android/support/v7/preference/Preference#onAttached())`() ` Called when the Preference hierarchy has been attached to the list of preferences.                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[onAttachedToHierarchy](https://developer.android.com/reference/android/support/v7/preference/Preference#onAttachedToHierarchy(android.support.v7.preference.PreferenceManager))`(`[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)` preferenceManager) ` Called when this Preference has been attached to a Preference hierarchy.                                                                                                                                                                                                 | | ` void`                                                                                                                                                 | ` `[onBindViewHolder](https://developer.android.com/reference/android/support/v7/preference/Preference#onBindViewHolder(android.support.v7.preference.PreferenceViewHolder))`(`[PreferenceViewHolder](https://developer.android.com/reference/android/support/v7/preference/PreferenceViewHolder)` holder) ` Binds the created View to the data for this Preference.                                                                                                                                                                                                                              | | ` void`                                                                                                                                                 | ` `[onClick](https://developer.android.com/reference/android/support/v7/preference/Preference#onClick())`() ` Processes a click on the preference.                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                 | ` `[onDependencyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#onDependencyChanged(android.support.v7.preference.Preference, boolean))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` dependency, boolean disableDependent) ` Called when the dependency changes.                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[onDetached](https://developer.android.com/reference/android/support/v7/preference/Preference#onDetached())`() ` Called when the Preference hierarchy has been detached from the list of preferences.                                                                                                                                                                                                                                                                                                                                                                                          | | ` Object`                                                                                                                                               | ` `[onGetDefaultValue](https://developer.android.com/reference/android/support/v7/preference/Preference#onGetDefaultValue(android.content.res.TypedArray, int))`(`[TypedArray](https://developer.android.com/reference/android/content/res/TypedArray.html)` a, int index) ` Called when a Preference is being inflated and the default value attribute needs to be read.                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/android/support/v7/preference/Preference#onInitializeAccessibilityNodeInfo(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat))`(`[AccessibilityNodeInfoCompat](https://developer.android.com/reference/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat)` info) ` Initializes an[AccessibilityNodeInfo](https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html)with information about the View for this Preference.                        | | ` void`                                                                                                                                                 | ` `[onParentChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#onParentChanged(android.support.v7.preference.Preference, boolean))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` parent, boolean disableChild) ` Called when the implicit parent dependency changes.                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[onPrepareForRemoval](https://developer.android.com/reference/android/support/v7/preference/Preference#onPrepareForRemoval())`() ` Called when this Preference is being removed from the hierarchy.                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/Preference#onRestoreInstanceState(android.os.Parcelable))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()).                                                                                      | | ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)                                                                     | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState())`() ` Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state.                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[onSetInitialValue](https://developer.android.com/reference/android/support/v7/preference/Preference#onSetInitialValue(boolean, java.lang.Object))`(boolean restorePersistedValue, Object defaultValue) ` Implement this to set the initial value of the Preference.                                                                                                                                                                                                                                                                                                                           | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                             | ` `[peekExtras](https://developer.android.com/reference/android/support/v7/preference/Preference#peekExtras())`() ` Return the extras Bundle object associated with this preference, returning null if there is not currently one.                                                                                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                                                              | ` `[persistBoolean](https://developer.android.com/reference/android/support/v7/preference/Preference#persistBoolean(boolean))`(boolean value) ` Attempts to persist a[Boolean](https://developer.android.com/reference/java/lang/Boolean)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                                                                              | ` `[persistFloat](https://developer.android.com/reference/android/support/v7/preference/Preference#persistFloat(float))`(float value) ` Attempts to persist a[Float](https://developer.android.com/reference/java/lang/Float)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[persistInt](https://developer.android.com/reference/android/support/v7/preference/Preference#persistInt(int))`(int value) ` Attempts to persist an[Integer](https://developer.android.com/reference/java/lang/Integer)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                              | ` `[persistLong](https://developer.android.com/reference/android/support/v7/preference/Preference#persistLong(long))`(long value) ` Attempts to persist a[Long](https://developer.android.com/reference/java/lang/Long)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                                                              | ` `[persistString](https://developer.android.com/reference/android/support/v7/preference/Preference#persistString(java.lang.String))`(String value) ` Attempts to persist a[String](https://developer.android.com/reference/java/lang/String)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[persistStringSet](https://developer.android.com/reference/android/support/v7/preference/Preference#persistStringSet(java.util.Set<java.lang.String>))`(Set<String> values) ` Attempts to persist a set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[restoreHierarchyState](https://developer.android.com/reference/android/support/v7/preference/Preference#restoreHierarchyState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Restore this Preference hierarchy's previously saved state from the given container.                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[saveHierarchyState](https://developer.android.com/reference/android/support/v7/preference/Preference#saveHierarchyState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Store this Preference hierarchy's frozen state into the given container.                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                                                                 | ` `[setDefaultValue](https://developer.android.com/reference/android/support/v7/preference/Preference#setDefaultValue(java.lang.Object))`(Object defaultValue) ` Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.                                                                                                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[setDependency](https://developer.android.com/reference/android/support/v7/preference/Preference#setDependency(java.lang.String))`(String dependencyKey) ` Sets the key of a Preference that this Preference will depend on.                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setEnabled](https://developer.android.com/reference/android/support/v7/preference/Preference#setEnabled(boolean))`(boolean enabled) ` Sets whether this Preference is enabled.                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                 | ` `[setFragment](https://developer.android.com/reference/android/support/v7/preference/Preference#setFragment(java.lang.String))`(String fragment) ` Sets the class name of a fragment to be shown when this Preference is clicked.                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#setIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Sets the icon for this Preference with a Drawable.                                                                                                                                                                                                                                                                                              | | ` void`                                                                                                                                                 | ` `[setIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#setIcon(int))`(int iconResId) ` Sets the icon for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setIconSpaceReserved](https://developer.android.com/reference/android/support/v7/preference/Preference#setIconSpaceReserved(boolean))`(boolean iconSpaceReserved) ` Sets whether to reserve the space of this Preference icon view when no icon is provided.                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                                                                 | ` `[setIntent](https://developer.android.com/reference/android/support/v7/preference/Preference#setIntent(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` Sets an[Intent](https://developer.android.com/reference/android/content/Intent.html)to be used for[startActivity(Intent)](https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent))when this Preference is clicked.                                                                                               | | ` void`                                                                                                                                                 | ` `[setKey](https://developer.android.com/reference/android/support/v7/preference/Preference#setKey(java.lang.String))`(String key) ` Sets the key for this Preference, which is used as a key to the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore).                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[setLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#setLayoutResource(int))`(int layoutResId) ` Sets the layout resource that is inflated as the[View](https://developer.android.com/reference/android/view/View.html)to be shown for this Preference.                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                 | ` `[setOnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#setOnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener))`(`[Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener)` onPreferenceChangeListener) ` Sets the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).                                                       | | ` void`                                                                                                                                                 | ` `[setOnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference#setOnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener))`(`[Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)` onPreferenceClickListener) ` Sets the callback to be invoked when this Preference is clicked.                                                                                                                          | | ` void`                                                                                                                                                 | ` `[setOrder](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))`(int order) ` Sets the order of this Preference with respect to other Preference objects on the same level.                                                                                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[setPersistent](https://developer.android.com/reference/android/support/v7/preference/Preference#setPersistent(boolean))`(boolean persistent) ` Sets whether this Preference is persistent.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[setPreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/Preference#setPreferenceDataStore(android.support.v7.preference.PreferenceDataStore))`(`[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)` dataStore) ` Sets a[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)to be used by this Preference instead of using[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). | | ` void`                                                                                                                                                 | ` `[setSelectable](https://developer.android.com/reference/android/support/v7/preference/Preference#setSelectable(boolean))`(boolean selectable) ` Sets whether this Preference is selectable.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[setShouldDisableView](https://developer.android.com/reference/android/support/v7/preference/Preference#setShouldDisableView(boolean))`(boolean shouldDisableView) ` Sets whether this Preference should disable its view when it gets disabled.                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setSingleLineTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setSingleLineTitle(boolean))`(boolean singleLineTitle) ` Sets whether to constrain the title of this Preference to a single line instead of letting it wrap onto multiple lines.                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[setSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#setSummary(java.lang.CharSequence))`(CharSequence summary) ` Sets the summary for this Preference with a CharSequence.                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[setSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#setSummary(int))`(int summaryResId) ` Sets the summary for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setTitle(java.lang.CharSequence))`(CharSequence title) ` Sets the title for this Preference with a CharSequence.                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setTitle(int))`(int titleResId) ` Sets the title for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[setViewId](https://developer.android.com/reference/android/support/v7/preference/Preference#setViewId(int))`(int viewId) ` Set the ID that will be assigned to the overall View representing this preference, once bound.                                                                                                                                                                                                                                                                                                                                                                     | | ` final void`                                                                                                                                           | ` `[setVisible](https://developer.android.com/reference/android/support/v7/preference/Preference#setVisible(boolean))`(boolean visible) ` Sets whether this preference should be visible in the list.                                                                                                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                                                                                 | ` `[setWidgetLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#setWidgetLayoutResource(int))`(int widgetLayoutResId) ` Sets the layout for the controllable widget portion of this Preference.                                                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                                                              | ` `[shouldDisableDependents](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldDisableDependents())`() ` Checks whether this preference's dependents should currently be disabled.                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                                                              | ` `[shouldPersist](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldPersist())`() ` Checks whether, at the given time this method is called, this Preference should store/restore its value(s) into the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or into[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)if assigned.                                                                                                               | | ` String`                                                                                                                                               | ` `[toString](https://developer.android.com/reference/android/support/v7/preference/Preference#toString())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#)From interface` java.lang.Comparable ` |-----------------|----------------------------------------------------------------------------------------------------------------------| | ` abstract int` | ` compareTo(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` arg0) ` | ||

## Public constructors

### EditTextPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
EditTextPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)
```

<br />

<br />

|              Parameters               ||
|----------------|-----------------------|
| `context`      | `Context` <br />      |
| `attrs`        | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br />          |
| `defStyleRes`  | `int` <br />          |

### EditTextPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
EditTextPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)
```

<br />

<br />

|              Parameters               ||
|----------------|-----------------------|
| `context`      | `Context` <br />      |
| `attrs`        | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br />          |

### EditTextPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
EditTextPreference (Context context, 
                AttributeSet attrs)
```

<br />

<br />

|            Parameters            ||
|-----------|-----------------------|
| `context` | `Context` <br />      |
| `attrs`   | `AttributeSet` <br /> |

### EditTextPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
EditTextPreference (Context context)
```

<br />

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

## Public methods

### getText

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String getText ()
```

Gets the text from the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html).

<br />

|                    Returns                     ||
|----------|--------------------------------------|
| `String` | The current preference value. <br /> |

### setText

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setText (String text)
```

Saves the text to the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html).

<br />

|                Parameters                 ||
|--------|-----------------------------------|
| `text` | `String`: The text to save <br /> |

### shouldDisableDependents

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean shouldDisableDependents ()
```

Checks whether this preference's dependents should currently be disabled.

<br />

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | True if the dependents should be disabled, otherwise false. <br /> |

## Protected methods

### onGetDefaultValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Object onGetDefaultValue (TypedArray a, 
                int index)
```

Called when a Preference is being inflated and the default value attribute needs to be read. Since different Preference types have different value types, the subclass should get and return the default value which will be its value type.

For example, if the value type is String, the body of the method would proxy to[getString(int)](https://developer.android.com/reference/android/content/res/TypedArray.html#getString(int)).

<br />

|                            Parameters                            ||
|---------|---------------------------------------------------------|
| `a`     | `TypedArray`: The set of attributes. <br />             |
| `index` | `int`: The index of the default value attribute. <br /> |

|                           Returns                           ||
|----------|---------------------------------------------------|
| `Object` | The default value of this preference type. <br /> |

### onRestoreInstanceState

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onRestoreInstanceState (Parcelable state)
```

Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()). This function will never be called with a null state.

<br />

|                                                                                                         Parameters                                                                                                         ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state` | `Parcelable`: The saved state that had previously been returned by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference#onSaveInstanceState()). <br /> |

### onSaveInstanceState

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Parcelable onSaveInstanceState ()
```

Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can be reconstructed later.

<br />

|                                                                                                                             Returns                                                                                                                             ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | A Parcelable object containing the current dynamic state of this Preference, or null if there is nothing interesting to save. The default implementation returns null. <br /> |

### onSetInitialValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetInitialValue (boolean restoreValue, 
                Object defaultValue)
```

Implement this to set the initial value of the Preference.

If<var translate="no">restorePersistedValue</var>is true, you should restore the Preference value from the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). If<var translate="no">restorePersistedValue</var>is false, you should set the Preference value to defaultValue that is given (and possibly store to SharedPreferences if[shouldPersist()](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldPersist())is true).

In case of using[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore), the<var translate="no">restorePersistedValue</var>is always`true`but the default value (if provided) is set.

This may not always be called. One example is if it should not persist but there is no default value given.

<br />

|                                                                    Parameters                                                                    ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------|
| `restoreValue` | `boolean`: True to restore the persisted value; false to use the given<var translate="no">defaultValue</var>. <br />             |
| `defaultValue` | `Object`: The default value for this Preference. Only use this if<var translate="no">restorePersistedValue</var>is false. <br /> |

-

  ## Interfaces

  - [DialogPreference.TargetFragment](https://developer.android.com/reference/android/support/v7/preference/DialogPreference.TargetFragment)
  - [Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener)
  - [Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)
  - [PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback)
  - [PreferenceFragmentCompat.OnPreferenceStartFragmentCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceStartFragmentCallback)
  - [PreferenceFragmentCompat.OnPreferenceStartScreenCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceStartScreenCallback)
  - [PreferenceGroup.PreferencePositionCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup.PreferencePositionCallback)
  - [PreferenceManager.OnDisplayPreferenceDialogListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnDisplayPreferenceDialogListener)
  - [PreferenceManager.OnNavigateToScreenListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnNavigateToScreenListener)
  - [PreferenceManager.OnPreferenceTreeClickListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnPreferenceTreeClickListener)
-

  ## Classes

  - [CheckBoxPreference](https://developer.android.com/reference/android/support/v7/preference/CheckBoxPreference)
  - [DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)
  - [DropDownPreference](https://developer.android.com/reference/android/support/v7/preference/DropDownPreference)
  - [EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference)
  - [EditTextPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/EditTextPreferenceDialogFragmentCompat)
  - [ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference)
  - [ListPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/ListPreferenceDialogFragmentCompat)
  - [MultiSelectListPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/MultiSelectListPreferenceDialogFragmentCompat)
  - [Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)
  - [Preference.BaseSavedState](https://developer.android.com/reference/android/support/v7/preference/Preference.BaseSavedState)
  - [PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory)
  - [PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)
  - [PreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceDialogFragmentCompat)
  - [PreferenceFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat)
  - [PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)
  - [PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)
  - [PreferenceManager.PreferenceComparisonCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.PreferenceComparisonCallback)
  - [PreferenceManager.SimplePreferenceComparisonCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.SimplePreferenceComparisonCallback)
  - [PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)
  - [PreferenceViewHolder](https://developer.android.com/reference/android/support/v7/preference/PreferenceViewHolder)
  - [R](https://developer.android.com/reference/android/support/v7/preference/R)
  - [R.anim](https://developer.android.com/reference/android/support/v7/preference/R.anim)
  - [R.attr](https://developer.android.com/reference/android/support/v7/preference/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/v7/preference/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/v7/preference/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/v7/preference/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/v7/preference/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/v7/preference/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/v7/preference/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/v7/preference/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/v7/preference/R.string)
  - [R.style](https://developer.android.com/reference/android/support/v7/preference/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/v7/preference/R.styleable)
  - [SeekBarPreference](https://developer.android.com/reference/android/support/v7/preference/SeekBarPreference)
  - [SwitchPreferenceCompat](https://developer.android.com/reference/android/support/v7/preference/SwitchPreferenceCompat)
  - [TwoStatePreference](https://developer.android.com/reference/android/support/v7/preference/TwoStatePreference)