# Preference.OnPreferenceChangeListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

# Preference.OnPreferenceChangeListener

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/preference/Preference.OnPreferenceChangeListener "View this page in Kotlin")\|Java

`
public
static


interface
Preference.OnPreferenceChangeListener
`  
`


`

|----------------------------------------------------------|
| android.preference.Preference.OnPreferenceChangeListener |

<br />

*** ** * ** ***

<br />

**This interface was deprecated in API level 29.**   
Use the[AndroidX](https://developer.android.com/jetpack/androidx)[Preference Library](https://developer.android.com/reference/androidx/preference/package-summary)for consistent behavior across all devices. For more information on using the AndroidX Preference Library see[Settings](https://developer.android.com/guide/topics/ui/settings).

Interface definition for a callback to be invoked when the value of this[Preference](https://developer.android.com/reference/android/preference/Preference)has been changed by the user and is about to be set and/or persisted. This gives the client a chance to prevent setting and/or persisting the value.

## Summary

|                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                        ||
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract boolean` | ` `[onPreferenceChange](https://developer.android.com/reference/android/preference/Preference.OnPreferenceChangeListener#onPreferenceChange(android.preference.Preference,%20java.lang.Object))`(`[Preference](https://developer.android.com/reference/android/preference/Preference)` preference, `[Object](https://developer.android.com/reference/java/lang/Object)` newValue) ` Called when a Preference has been changed by the user. |

## Public methods

### onPreferenceChange

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean onPreferenceChange (Preference preference, 
                Object newValue)
```

Called when a Preference has been changed by the user. This is called before the state of the Preference is about to be updated and before the state is persisted.

<br />

|                           Parameters                            ||
|--------------|---------------------------------------------------|
| `preference` | `Preference`: The changed Preference. <br />      |
| `newValue`   | `Object`: The new value of the Preference. <br /> |

|                                     Returns                                      ||
|-----------|-----------------------------------------------------------------------|
| `boolean` | True to update the state of the Preference with the new value. <br /> |