# PreferenceGroup

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

*** ** * ** ***


```
public abstract class PreferenceGroup extends Preference
```

<br />

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

Known direct subclasses [PreferenceCategory](https://developer.android.com/reference/androidx/preference/PreferenceCategory), [PreferenceScreen](https://developer.android.com/reference/androidx/preference/PreferenceScreen)

|---|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceCategory` | A container that is used to group similar `https://developer.android.com/reference/androidx/preference/Preference`s. |
| `https://developer.android.com/reference/androidx/preference/PreferenceScreen` | A top-level container that represents a settings screen. |

*** ** * ** ***

A container for multiple `https://developer.android.com/reference/androidx/preference/Preference`s. It is a base class for preference objects that are parents, such as `https://developer.android.com/reference/androidx/preference/PreferenceCategory` and `https://developer.android.com/reference/androidx/preference/PreferenceScreen`.

name android:orderingFromXml

name initialExpandedChildrenCount

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/preference/PreferenceGroup.PreferencePositionCallback` Interface for PreferenceGroup adapters to implement so that `https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat#scrollToPreference(java.lang.String)` and `https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat#scrollToPreference(androidx.preference.Preference)` can determine the correct scroll position to request. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#PreferenceGroup(android.content.Context,android.util.AttributeSet)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#PreferenceGroup(android.content.Context,android.util.AttributeSet,int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/AttributeSet.html attrs, int defStyleAttr )` |
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#PreferenceGroup(android.content.Context,android.util.AttributeSet,int,int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/AttributeSet.html attrs, int defStyleAttr, int defStyleRes )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#addItemFromInflater(androidx.preference.Preference)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference)` Called by the inflater to add an item to this group. |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#addPreference(androidx.preference.Preference)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference)` Adds a `https://developer.android.com/reference/androidx/preference/Preference` at the correct position based on the preference's order. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable T` | `<T extends https://developer.android.com/reference/androidx/preference/Preference> https://developer.android.com/reference/androidx/preference/PreferenceGroup#findPreference(java.lang.CharSequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key)` Finds a `https://developer.android.com/reference/androidx/preference/Preference` based on its key. |
| `int` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#getInitialExpandedChildrenCount()()` Gets the maximal number of children that are initially shown. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#getPreference(int)(int index)` Returns the `https://developer.android.com/reference/androidx/preference/Preference` at a particular index. |
| `int` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#getPreferenceCount()()` Returns the number of children `https://developer.android.com/reference/androidx/preference/Preference`s. |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#isOrderingAsAdded()()` Whether this group is ordering preferences in the order they are added. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#notifyDependencyChange(boolean)(boolean disableDependents)` Notifies any listening dependents of a change that affects the dependency. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#onAttached()()` Called when the preference hierarchy has been attached to the list of preferences. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#onDetached()()` Called when the preference hierarchy has been detached from the list of preferences. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#removeAll()()` Removes all `https://developer.android.com/reference/androidx/preference/Preference`s from this group. |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#removePreference(androidx.preference.Preference)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference)` Removes a `https://developer.android.com/reference/androidx/preference/Preference` from this group. |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#removePreferenceRecursively(java.lang.CharSequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key)` Recursively finds and removes a `https://developer.android.com/reference/androidx/preference/Preference` from this group or a nested group lower down in the hierarchy. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#setInitialExpandedChildrenCount(int)(int expandedCount)` Sets the maximal number of children that are shown when the preference group is launched where the rest of the children will be hidden. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#setOrderingAsAdded(boolean)(boolean orderingAsAdded)` Whether to order the `https://developer.android.com/reference/androidx/preference/Preference` children of this group as they are added. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#dispatchRestoreInstanceState(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html container)` Called by `https://developer.android.com/reference/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` to retrieve the saved state for this preference and its children. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#dispatchSaveInstanceState(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html container)` Called by `https://developer.android.com/reference/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` to store the instance for this preference and its children. |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#isOnSameScreenAsChildren()()` Whether this preference group should be shown on the same screen as its contained preferences. |
| `boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#onPrepareAddPreference(androidx.preference.Preference)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference)` Prepares a `https://developer.android.com/reference/androidx/preference/Preference` to be added to the group. |
| `void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#onRestoreInstanceState(android.os.Parcelable)(@https://developer.android.com/reference/androidx/annotation/Nullable 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 `https://developer.android.com/reference/androidx/preference/Preference#onSaveInstanceState()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Parcelable.html` | `https://developer.android.com/reference/androidx/preference/PreferenceGroup#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. |

| ### Extension functions |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).contains(androidx.preference.Preference)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference )` Returns `true` if `preference` is found in this preference group. |
| `final void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).forEach(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action on each preference in this preference group. |
| `final void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).forEachIndexed(kotlin.Function2)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action on each preference in this preference group, providing its sequential index. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).get(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, int index)` Returns the preference at `index`. |
| `final T` | `<T extends https://developer.android.com/reference/androidx/preference/Preference> https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).get(kotlin.CharSequence)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key )` Returns the preference with `key`, or `null` if no preference with `key` is found. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference>` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).getChildren()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver)` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` over the preferences in this preference group. |
| `final int` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).getSize()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver)` Returns the number of preferences in this preference group. |
| `final boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).isEmpty()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver)` Returns true if this preference group contains no preferences. |
| `final boolean` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).isNotEmpty()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver)` Returns true if this preference group contains one or more preferences. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Iterator.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference>` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).iterator()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver)` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterator/index.html` over the preferences in this preference group. |
| `final void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).minusAssign(androidx.preference.Preference)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference )` Removes `preference` from this preference group. |
| `final void` | `https://developer.android.com/reference/androidx/preference/PreferenceGroupKt.https://developer.android.com/reference/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).plusAssign(androidx.preference.Preference)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceGroup receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference )` Adds `preference` to this preference group. |

| ### Inherited Constants |
|---|
| From [androidx.preference.Preference](https://developer.android.com/reference/androidx/preference/Preference) |---|---| | `static final int` | `https://developer.android.com/reference/androidx/preference/Preference#DEFAULT_ORDER() = 2147483647` Specify for `https://developer.android.com/reference/androidx/preference/Preference#setOrder(int)` if a specific order is not required. | |

| ### Inherited methods |
|---|
| From [java.lang.Comparable](https://developer.android.com/reference/java/lang/Comparable.html) |---|---| | `abstract int` | `https://developer.android.com/reference/java/lang/Comparable.html#compareTo(T)(T p)` | |
| From [androidx.preference.Preference](https://developer.android.com/reference/androidx/preference/Preference) |---|---| | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#callChangeListener(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html newValue)` Call this method after the user changes the preference, but before the internal state is set. | | `int` | `https://developer.android.com/reference/androidx/preference/Preference#compareTo(androidx.preference.Preference)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference another)` Compares preference objects based on order (if set), otherwise alphabetically on the titles. | | `@https://developer.android.com/reference/androidx/annotation/Nullable T` | `<T extends https://developer.android.com/reference/androidx/preference/Preference> https://developer.android.com/reference/androidx/preference/Preference#findPreferenceInHierarchy(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html key)` Finds a preference in the entire hierarchy (above or below this preference) with the given key. | | `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/androidx/preference/Preference#getContext()()` Returns the `https://developer.android.com/reference/android/content/Context.html` of this preference. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/preference/Preference#getDependency()()` Returns the key of the dependency on this preference. | | `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/preference/Preference#getExtras()()` Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/preference/Preference#getFragment()()` Return the fragment class name associated with this preference. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `https://developer.android.com/reference/androidx/preference/Preference#getIcon()()` Returns the icon of this preference. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/Intent.html` | `https://developer.android.com/reference/androidx/preference/Preference#getIntent()()` Return the `https://developer.android.com/reference/android/content/Intent.html` associated with this preference. | | `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/preference/Preference#getKey()()` Gets the key for this preference, which is also the key used for storing values into `https://developer.android.com/reference/android/content/SharedPreferences.html` or `https://developer.android.com/reference/androidx/preference/PreferenceDataStore`. | | `final int` | `https://developer.android.com/reference/androidx/preference/Preference#getLayoutResource()()` Gets the layout resource that will be shown as the `https://developer.android.com/reference/android/view/View.html` for this preference. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/Preference.OnPreferenceChangeListener` | `https://developer.android.com/reference/androidx/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). | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/Preference.OnPreferenceClickListener` | `https://developer.android.com/reference/androidx/preference/Preference#getOnPreferenceClickListener()()` Returns the callback to be invoked when this preference is clicked. | | `int` | `https://developer.android.com/reference/androidx/preference/Preference#getOrder()()` Gets the order of this preference with respect to other preference objects on the same level. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/PreferenceGroup` | `https://developer.android.com/reference/androidx/preference/Preference#getParent()()` Returns the `https://developer.android.com/reference/androidx/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` | `https://developer.android.com/reference/androidx/preference/Preference#getPersistedBoolean(boolean)(boolean defaultReturnValue)` Attempts to get a persisted `https://developer.android.com/reference/java/lang/Boolean.html` if this preference is persistent. | | `float` | `https://developer.android.com/reference/androidx/preference/Preference#getPersistedFloat(float)(float defaultReturnValue)` Attempts to get a persisted `https://developer.android.com/reference/java/lang/Float.html` if this preference is persistent. | | `int` | `https://developer.android.com/reference/androidx/preference/Preference#getPersistedInt(int)(int defaultReturnValue)` Attempts to get a persisted `https://developer.android.com/reference/java/lang/Integer.html` if this preference is persistent. | | `long` | `https://developer.android.com/reference/androidx/preference/Preference#getPersistedLong(long)(long defaultReturnValue)` Attempts to get a persisted `https://developer.android.com/reference/java/lang/Long.html` if this preference is persistent. | | `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/preference/Preference#getPersistedString(java.lang.String)(https://developer.android.com/reference/java/lang/String.html defaultReturnValue)` Attempts to get a persisted set of Strings if this preference is persistent. | | `https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/preference/Preference#getPersistedStringSet(java.util.Set<java.lang.String>)(https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> defaultReturnValue)` Attempts to get a persisted set of Strings if this preference is persistent. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/PreferenceDataStore` | `https://developer.android.com/reference/androidx/preference/Preference#getPreferenceDataStore()()` Returns `https://developer.android.com/reference/androidx/preference/PreferenceDataStore` used by this preference. | | `https://developer.android.com/reference/androidx/preference/PreferenceManager` | `https://developer.android.com/reference/androidx/preference/Preference#getPreferenceManager()()` Gets the `https://developer.android.com/reference/androidx/preference/PreferenceManager` that manages this preference object's tree. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/SharedPreferences.html` | `https://developer.android.com/reference/androidx/preference/Preference#getSharedPreferences()()` Returns the `https://developer.android.com/reference/android/content/SharedPreferences.html` where this preference can read its value(s). | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#getShouldDisableView()()` Checks whether this preference should disable its view when it's action is disabled. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/preference/Preference#getSummary()()` Returns the summary of this preference. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider` | `https://developer.android.com/reference/androidx/preference/Preference#getSummaryProvider()()` Returns the `https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider` used to configure the summary of this preference. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/preference/Preference#getTitle()()` Returns the title of this preference. | | `final int` | `https://developer.android.com/reference/androidx/preference/Preference#getWidgetLayoutResource()()` Gets the layout resource for the controllable widget portion of this preference. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#hasKey()()` Checks whether this preference has a valid key. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isCopyingEnabled()()` Returns whether the summary of this preference can be copied to the clipboard by long pressing on the preference. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isEnabled()()` Checks whether this preference should be enabled in the list. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isIconSpaceReserved()()` Returns whether the space of this preference icon view is reserved. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isPersistent()()` Checks whether this preference is persistent. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isSelectable()()` Checks whether this preference should be selectable in the list. | | `final boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isShown()()` Checks whether this preference is shown to the user in the hierarchy. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isSingleLineTitle()()` Gets whether the title of this preference is constrained to a single line. | | `final boolean` | `https://developer.android.com/reference/androidx/preference/Preference#isVisible()()` Checks whether this preference should be visible to the user. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#notifyChanged()()` Should be called when the data of this `https://developer.android.com/reference/androidx/preference/Preference` has changed. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#notifyHierarchyChanged()()` Should be called when a preference has been added/removed from this group, or the ordering should be re-evaluated. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onAttachedToHierarchy(androidx.preference.PreferenceManager)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceManager preferenceManager)` Called when this preference has been attached to a preference hierarchy. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onBindViewHolder(androidx.preference.PreferenceViewHolder)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/PreferenceViewHolder holder)` Binds the created View to the data for this preference. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onClick()()` Processes a click on the preference. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onDependencyChanged(androidx.preference.Preference,boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference dependency, boolean disableDependent )` Called when the dependency changes. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/preference/Preference#onGetDefaultValue(android.content.res.TypedArray,int)(@https://developer.android.com/reference/androidx/annotation/NonNull 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` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/androidx/preference/Preference#onInitializeAccessibilityNodeInfo(androidx.core.view.accessibility.AccessibilityNodeInfoCompat))(https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat info)` **This method is deprecated.** Preferences aren't views. <br /> | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onParentChanged(androidx.preference.Preference,boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference parent, boolean disableChild)` Called when the implicit parent dependency changes. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onPrepareForRemoval()()` Called when this preference is being removed from the hierarchy. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#onSetInitialValue(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html defaultValue)` Implement this to set the initial value of the preference. | | `void` | `[onSetInitialValue](https://developer.android.com/reference/androidx/preference/Preference#onSetInitialValue(boolean,java.lang.Object))(boolean restorePersistedValue, https://developer.android.com/reference/java/lang/Object.html defaultValue)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/preference/Preference#onSetInitialValue(java.lang.Object)` instead. <br /> | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/preference/Preference#peekExtras()()` Return the extras Bundle object associated with this preference, returning `null` if there is not currently one. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#persistBoolean(boolean)(boolean value)` Attempts to persist a `https://developer.android.com/reference/java/lang/Boolean.html` if this preference is persistent. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#persistFloat(float)(float value)` Attempts to persist a `https://developer.android.com/reference/java/lang/Float.html` if this preference is persistent. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#persistInt(int)(int value)` Attempts to persist an `https://developer.android.com/reference/java/lang/Integer.html` if this preference is persistent. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#persistLong(long)(long value)` Attempts to persist a `https://developer.android.com/reference/java/lang/Long.html` if this preference is persistent. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#persistString(java.lang.String)(https://developer.android.com/reference/java/lang/String.html value)` Attempts to persist a `https://developer.android.com/reference/java/lang/String.html` if this preference is persistent. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#persistStringSet(java.util.Set<java.lang.String>)(https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html> values)` Attempts to persist a set of Strings if this preference is persistent. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html container)` Restore this preference hierarchy's previously saved state from the given container. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html container)` Store this preference hierarchy's frozen state into the given container. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setCopyingEnabled(boolean)(boolean enabled)` Sets whether the summary of this preference can be copied to the clipboard by long pressing on the preference. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setDefaultValue(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html 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` | `https://developer.android.com/reference/androidx/preference/Preference#setDependency(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html dependencyKey)` Sets the key of a preference that this preference will depend on. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setEnabled(boolean)(boolean enabled)` Sets whether this preference is enabled. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setFragment(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html fragment)` Sets the class name of a fragment to be shown when this preference is clicked. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setIcon(android.graphics.drawable.Drawable)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/graphics/drawable/Drawable.html icon)` Sets the icon for this preference with a Drawable. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setIcon(int)(int iconResId)` Sets the icon for this preference with a resource ID. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setIconSpaceReserved(boolean)(boolean iconSpaceReserved)` Sets whether to reserve the space of this preference icon view when no icon is provided. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setIntent(android.content.Intent)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/Intent.html intent)` Sets an `https://developer.android.com/reference/android/content/Intent.html` to be used for `https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent)` when this preference is clicked. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setKey(java.lang.String)(https://developer.android.com/reference/java/lang/String.html key)` Sets the key for this preference, which is used as a key to the `https://developer.android.com/reference/android/content/SharedPreferences.html` or `https://developer.android.com/reference/androidx/preference/PreferenceDataStore`. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setLayoutResource(int)(int layoutResId)` Sets the layout resource that is inflated as the `https://developer.android.com/reference/android/view/View.html` to be shown for this preference. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setOnPreferenceChangeListener(androidx.preference.Preference.OnPreferenceChangeListener)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/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` | `https://developer.android.com/reference/androidx/preference/Preference#setOnPreferenceClickListener(androidx.preference.Preference.OnPreferenceClickListener)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/Preference.OnPreferenceClickListener onPreferenceClickListener )` Sets the callback to be invoked when this preference is clicked. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setOrder(int)(int order)` Sets the order of this preference with respect to other preference objects on the same level. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setPersistent(boolean)(boolean persistent)` Sets whether this preference is persistent. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setPreferenceDataStore(androidx.preference.PreferenceDataStore)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/PreferenceDataStore dataStore)` Sets a `https://developer.android.com/reference/androidx/preference/PreferenceDataStore` to be used by this preference instead of using `https://developer.android.com/reference/android/content/SharedPreferences.html`. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setSelectable(boolean)(boolean selectable)` Sets whether this preference is selectable. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setShouldDisableView(boolean)(boolean shouldDisableView)` Sets whether this preference should disable its view when it gets disabled. | | `void` | `https://developer.android.com/reference/androidx/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` | `https://developer.android.com/reference/androidx/preference/Preference#setSummary(java.lang.CharSequence)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html summary)` Sets the summary for this preference with a CharSequence. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setSummary(int)(int summaryResId)` Sets the summary for this preference with a resource ID. | | `final void` | `https://developer.android.com/reference/androidx/preference/Preference#setSummaryProvider(androidx.preference.Preference.SummaryProvider)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider summaryProvider)` Set a `https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider` that will be invoked whenever the summary of this preference is requested. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setTitle(java.lang.CharSequence)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html title)` Sets the title for this preference with a CharSequence. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setTitle(int)(int titleResId)` Sets the title for this preference with a resource ID. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setViewId(int)(int viewId)` Set the ID that will be assigned to the overall View representing this preference, once bound. | | `final void` | `https://developer.android.com/reference/androidx/preference/Preference#setVisible(boolean)(boolean visible)` Sets whether this preference should be visible to the user. | | `void` | `https://developer.android.com/reference/androidx/preference/Preference#setWidgetLayoutResource(int)(int widgetLayoutResId)` Sets the layout for the controllable widget portion of this preference. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#shouldDisableDependents()()` Checks whether this preference's dependents should currently be disabled. | | `boolean` | `https://developer.android.com/reference/androidx/preference/Preference#shouldPersist()()` Checks whether, at the given time this method is called, this preference should store/restore its value(s) into the `https://developer.android.com/reference/android/content/SharedPreferences.html` or into `https://developer.android.com/reference/androidx/preference/PreferenceDataStore` if assigned. | | `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/preference/Preference#toString()()` | |

## Public constructors

### PreferenceGroup

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

```
public PreferenceGroup(@NonNull Context context, @Nullable AttributeSet attrs)
```

### PreferenceGroup

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

```
public PreferenceGroup(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)
```

### PreferenceGroup

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

```
public PreferenceGroup(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr,
    int defStyleRes
)
```

## Public methods

### addItemFromInflater

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

```
public void addItemFromInflater(@NonNull Preference preference)
```

Called by the inflater to add an item to this group.

### addPreference

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

```
public boolean addPreference(@NonNull Preference preference)
```

Adds a `https://developer.android.com/reference/androidx/preference/Preference` at the correct position based on the preference's order.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference` | The preference to add |

| Returns |
|---|---|
| `boolean` | Whether the preference is now in this group |

### findPreference

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

```
public @Nullable T <T extends Preference> findPreference(@NonNull CharSequence key)
```

Finds a `https://developer.android.com/reference/androidx/preference/Preference` based on its key. If two `https://developer.android.com/reference/androidx/preference/Preference`s share the same key (not recommended), the first to appear will be returned.

This will recursively search for the `https://developer.android.com/reference/androidx/preference/Preference` in any children that are also `https://developer.android.com/reference/androidx/preference/PreferenceGroup`s.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key` | The key of the `https://developer.android.com/reference/androidx/preference/Preference` to retrieve |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable T` | The `https://developer.android.com/reference/androidx/preference/Preference` with the key, or `null` |

### getInitialExpandedChildrenCount

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

```
public int getInitialExpandedChildrenCount()
```

Gets the maximal number of children that are initially shown.

| Returns |
|---|---|
| `int` | The maximal number of children that are initially shown initialExpandedChildrenCount |

### getPreference

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

```
public @NonNull Preference getPreference(int index)
```

Returns the `https://developer.android.com/reference/androidx/preference/Preference` at a particular index.

| Parameters |
|---|---|
| `int index` | The index of the `https://developer.android.com/reference/androidx/preference/Preference` to retrieve |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference` | The `https://developer.android.com/reference/androidx/preference/Preference` |

### getPreferenceCount

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

```
public int getPreferenceCount()
```

Returns the number of children `https://developer.android.com/reference/androidx/preference/Preference`s.

| Returns |
|---|---|
| `int` | The number of preference children in this group |

### isOrderingAsAdded

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

```
public boolean isOrderingAsAdded()
```

Whether this group is ordering preferences in the order they are added.

| Returns |
|---|---|
| `boolean` | Whether this group orders based on the order the children are added |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#setOrderingAsAdded(boolean)` |   |

### notifyDependencyChange

```
public void notifyDependencyChange(boolean disableDependents)
```

Notifies any listening dependents of a change that affects the dependency.

| Parameters |
|---|---|
| `boolean disableDependents` | Whether this preference should disable its dependents. |

### onAttached

```
public void onAttached()
```

Called when the preference hierarchy has been attached to the list of preferences. This can also be called when this preference has been attached to a group that was already attached to the list of preferences.

### onDetached

```
public void onDetached()
```

Called when the preference hierarchy has been detached from the list of preferences. This can also be called when this preference has been removed from a group that was attached to the list of preferences.

### removeAll

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

```
public void removeAll()
```

Removes all `https://developer.android.com/reference/androidx/preference/Preference`s from this group.

### removePreference

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

```
public boolean removePreference(@NonNull Preference preference)
```

Removes a `https://developer.android.com/reference/androidx/preference/Preference` from this group.

Note: This action is not recursive, and will only remove a preference if it exists in this group, ignoring preferences found in nested groups. Use `https://developer.android.com/reference/androidx/preference/PreferenceGroup#removePreferenceRecursively(java.lang.CharSequence)` to recursively find and remove a preference.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference` | The preference to remove |

| Returns |
|---|---|
| `boolean` | Whether the preference was found and removed |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#removePreferenceRecursively(java.lang.CharSequence)` |   |

### removePreferenceRecursively

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

```
public boolean removePreferenceRecursively(@NonNull CharSequence key)
```

Recursively finds and removes a `https://developer.android.com/reference/androidx/preference/Preference` from this group or a nested group lower down in the hierarchy. If two `https://developer.android.com/reference/androidx/preference/Preference`s share the same key (not recommended), the first to appear will be removed.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key` | The key of the preference to remove |

| Returns |
|---|---|
| `boolean` | Whether the preference was found and removed |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#findPreference(java.lang.CharSequence)` |   |

### setInitialExpandedChildrenCount

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

```
public void setInitialExpandedChildrenCount(int expandedCount)
```

Sets the maximal number of children that are shown when the preference group is launched where the rest of the children will be hidden. If some children are hidden an expand button will be provided to show all the hidden children. Any child in any level of the hierarchy that is also a preference group (e.g. preference category) will not be counted towards the limit. But instead the children of such group will be counted. By default, all children will be shown, so the default value of this attribute is equal to Integer.MAX_VALUE.

Note: The group should have a key defined if an expandable preference is present to correctly persist state.

| Parameters |
|---|---|
| `int expandedCount` | The number of children that is initially shown initialExpandedChildrenCount |

### setOrderingAsAdded

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

```
public void setOrderingAsAdded(boolean orderingAsAdded)
```

Whether to order the `https://developer.android.com/reference/androidx/preference/Preference` children of this group as they are added. If this is false, the ordering will follow each Preference order and default to alphabetic for those without an order.

If this is called after preferences are added, they will not be re-ordered in the order they were added, hence call this method early on.

| Parameters |
|---|---|
| `boolean orderingAsAdded` | Whether to order according to the order added |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/Preference#setOrder(int)` |   |

## Protected methods

### dispatchRestoreInstanceState

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

```
protected void dispatchRestoreInstanceState(@NonNull Bundle container)
```

Called by `https://developer.android.com/reference/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` to retrieve the saved state for this preference and its children. May be overridden to modify how restoring happens to the children of a preference. For example, some preference objects may not want to save state for their children.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html container` | The Bundle that holds the previously saved state |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` |   |
| `https://developer.android.com/reference/androidx/preference/Preference#onRestoreInstanceState(android.os.Parcelable)` |   |

### dispatchSaveInstanceState

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

```
protected void dispatchSaveInstanceState(@NonNull Bundle container)
```

Called by `https://developer.android.com/reference/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` to store the instance for this preference and its children. May be overridden to modify how the save happens for children. For example, some preference objects may want to not store an instance for their children.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html container` | The Bundle in which to save the instance of this preference |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` |   |
| `https://developer.android.com/reference/androidx/preference/Preference#onSaveInstanceState()` |   |

### isOnSameScreenAsChildren

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

```
protected boolean isOnSameScreenAsChildren()
```

Whether this preference group should be shown on the same screen as its contained preferences.

| Returns |
|---|---|
| `boolean` | `true` if the contained preferences should be shown on the same screen as this preference. |

### onPrepareAddPreference

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

```
protected boolean onPrepareAddPreference(@NonNull Preference preference)
```

Prepares a `https://developer.android.com/reference/androidx/preference/Preference` to be added to the group.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/preference/Preference preference` | The preference to add |

| Returns |
|---|---|
| `boolean` | Whether to allow adding the preference (`true`), or not (`false`) |

### onRestoreInstanceState

```
protected void onRestoreInstanceState(@Nullable Parcelable state)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Parcelable.html state` | The saved state that had previously been returned by `https://developer.android.com/reference/androidx/preference/Preference#onSaveInstanceState()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/Preference#onSaveInstanceState()` |   |
| `https://developer.android.com/reference/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` |   |

### onSaveInstanceState

```
protected @NonNull 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.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull 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`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/Preference#onRestoreInstanceState(android.os.Parcelable)` |   |
| `https://developer.android.com/reference/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` |   |

## Extension functions

### PreferenceGroupKt.contains

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:contains)

```
public final boolean PreferenceGroupKt.contains(
    @NonNull PreferenceGroup receiver,
    @NonNull Preference preference
)
```

Returns `true` if `preference` is found in this preference group.

### PreferenceGroupKt.forEach

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:forEach)

```
public final void PreferenceGroupKt.forEach(
    @NonNull PreferenceGroup receiver,
    @NonNull Function1<@NonNull Preference, Unit> action
)
```

Performs the given action on each preference in this preference group.

### PreferenceGroupKt.forEachIndexed

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:forEachIndexed)

```
public final void PreferenceGroupKt.forEachIndexed(
    @NonNull PreferenceGroup receiver,
    @NonNull Function2<@NonNull Integer, @NonNull Preference, Unit> action
)
```

Performs the given action on each preference in this preference group, providing its sequential index.

### PreferenceGroupKt.get

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:get)

```
public final @NonNull Preference PreferenceGroupKt.get(@NonNull PreferenceGroup receiver, int index)
```

Returns the preference at `index`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if index is less than 0 or greater than or equal to the count. |

### PreferenceGroupKt.get

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:get)

```
public final T <T extends Preference> PreferenceGroupKt.get(
    @NonNull PreferenceGroup receiver,
    @NonNull CharSequence key
)
```

Returns the preference with `key`, or `null` if no preference with `key` is found.

### PreferenceGroupKt.getChildren

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+symbol:children)

```
public final @NonNull Sequence<@NonNull Preference> PreferenceGroupKt.getChildren(@NonNull PreferenceGroup receiver)
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` over the preferences in this preference group.

### PreferenceGroupKt.getSize

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+symbol:size)

```
public final int PreferenceGroupKt.getSize(@NonNull PreferenceGroup receiver)
```

Returns the number of preferences in this preference group.

### PreferenceGroupKt.isEmpty

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:isEmpty)

```
public final boolean PreferenceGroupKt.isEmpty(@NonNull PreferenceGroup receiver)
```

Returns true if this preference group contains no preferences.

### PreferenceGroupKt.isNotEmpty

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:isNotEmpty)

```
public final boolean PreferenceGroupKt.isNotEmpty(@NonNull PreferenceGroup receiver)
```

Returns true if this preference group contains one or more preferences.

### PreferenceGroupKt.iterator

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:iterator)

```
public final @NonNull Iterator<@NonNull Preference> PreferenceGroupKt.iterator(@NonNull PreferenceGroup receiver)
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterator/index.html` over the preferences in this preference group.

### PreferenceGroupKt.minusAssign

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:minusAssign)

```
public final void PreferenceGroupKt.minusAssign(
    @NonNull PreferenceGroup receiver,
    @NonNull Preference preference
)
```

Removes `preference` from this preference group.

### PreferenceGroupKt.plusAssign

Artifact: [androidx.preference:preference-ktx](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/PreferenceGroup.kt+function:plusAssign)

```
public final void PreferenceGroupKt.plusAssign(
    @NonNull PreferenceGroup receiver,
    @NonNull Preference preference
)
```

Adds `preference` to this preference group.