# PreferenceManager.SimplePreferenceComparisonCallback

Artifact: [androidx.preference:preference](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceManager.java+class:androidx.preference.PreferenceManager.SimplePreferenceComparisonCallback) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

*** ** * ** ***


```
public class PreferenceManager.SimplePreferenceComparisonCallback extends PreferenceManager.PreferenceComparisonCallback
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.preference.PreferenceManager.PreferenceComparisonCallback](https://developer.android.com/reference/androidx/preference/PreferenceManager.PreferenceComparisonCallback) ||
|   | ↳ | [androidx.preference.PreferenceManager.SimplePreferenceComparisonCallback](https://developer.android.com/reference/androidx/preference/PreferenceManager.SimplePreferenceComparisonCallback) |

*** ** * ** ***

A basic implementation of `https://developer.android.com/reference/androidx/preference/PreferenceManager.PreferenceComparisonCallback` suitable for use with the default `https://developer.android.com/reference/androidx/preference/Preference` classes. If the `https://developer.android.com/reference/androidx/preference/PreferenceScreen` contains custom `https://developer.android.com/reference/androidx/preference/Preference` subclasses, you must override `https://developer.android.com/reference/androidx/preference/PreferenceManager.SimplePreferenceComparisonCallback#arePreferenceContentsTheSame(androidx.preference.Preference,androidx.preference.Preference)`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceManager.SimplePreferenceComparisonCallback#SimplePreferenceComparisonCallback()()` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceManager.SimplePreferenceComparisonCallback#arePreferenceContentsTheSame(androidx.preference.Preference,androidx.preference.Preference)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference p1, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference p2 )` Called to determine if two objects will display the same data |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceManager.SimplePreferenceComparisonCallback#arePreferenceItemsTheSame(androidx.preference.Preference,androidx.preference.Preference)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference p1, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference p2)` Called to determine if two objects represent the same item |

## Public constructors

### SimplePreferenceComparisonCallback

Added in 1.0.0

```
public SimplePreferenceComparisonCallback()
```

## Public methods

### arePreferenceContentsTheSame

Added in [1.3.0-alpha01](https://developer.android.com/jetpack/androidx/releases/preference#1.3.0-alpha01)

```
public boolean arePreferenceContentsTheSame(
    @NonNull Preference p1,
    @NonNull Preference p2
)
```

Called to determine if two objects will display the same data

The result of this method is only valid for the default `https://developer.android.com/reference/androidx/preference/Preference` objects, and custom subclasses which do not override `https://developer.android.com/reference/androidx/preference/Preference#onBindViewHolder(androidx.preference.PreferenceViewHolder)`. This method also assumes that if a preference object is being replaced by a new instance, the old instance was not modified after being removed from its containing `https://developer.android.com/reference/androidx/preference/PreferenceGroup`.

### arePreferenceItemsTheSame

Added in [1.3.0-alpha01](https://developer.android.com/jetpack/androidx/releases/preference#1.3.0-alpha01)

```
public boolean arePreferenceItemsTheSame(@NonNull Preference p1, @NonNull Preference p2)
```

Called to determine if two objects represent the same item

This method will not be able to track replaced `https://developer.android.com/reference/androidx/preference/Preference` objects if they do not have a unique key.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/Preference#setKey(java.lang.String)` |   |