# 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)

*** ** * ** ***


```
abstract class PreferenceGroup : Preference
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.preference.Preference](https://developer.android.com/reference/kotlin/androidx/preference/Preference) ||
|   | ↳ | [androidx.preference.PreferenceGroup](https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup) |

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

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

*** ** * ** ***

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

name android:orderingFromXml

name initialExpandedChildrenCount

## Summary

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

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#PreferenceGroup(android.content.Context,android.util.AttributeSet)(context: https://developer.android.com/reference/android/content/Context.html, attrs: https://developer.android.com/reference/android/util/AttributeSet.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#PreferenceGroup(android.content.Context,android.util.AttributeSet,int)(context: https://developer.android.com/reference/android/content/Context.html, attrs: https://developer.android.com/reference/android/util/AttributeSet.html?, defStyleAttr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#PreferenceGroup(android.content.Context,android.util.AttributeSet,int,int)( context: https://developer.android.com/reference/android/content/Context.html, attrs: https://developer.android.com/reference/android/util/AttributeSet.html?, defStyleAttr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, defStyleRes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

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

| ### Protected functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#dispatchRestoreInstanceState(android.os.Bundle)(container: https://developer.android.com/reference/android/os/Bundle.html)` Called by `https://developer.android.com/reference/kotlin/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` to retrieve the saved state for this preference and its children. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#dispatchSaveInstanceState(android.os.Bundle)(container: https://developer.android.com/reference/android/os/Bundle.html)` Called by `https://developer.android.com/reference/kotlin/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` to store the instance for this preference and its children. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#isOnSameScreenAsChildren()()` Whether this preference group should be shown on the same screen as its contained preferences. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#onPrepareAddPreference(androidx.preference.Preference)(preference: https://developer.android.com/reference/kotlin/androidx/preference/Preference)` Prepares a `https://developer.android.com/reference/kotlin/androidx/preference/Preference` to be added to the group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#onRestoreInstanceState(android.os.Parcelable)(state: https://developer.android.com/reference/android/os/Parcelable.html?)` Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onSaveInstanceState()`. |
| `https://developer.android.com/reference/android/os/Parcelable.html` | `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).contains(androidx.preference.Preference)(preference: https://developer.android.com/reference/kotlin/androidx/preference/Preference)` Returns `true` if `preference` is found in this preference group. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).forEach(kotlin.Function1)(action: (preference: https://developer.android.com/reference/kotlin/androidx/preference/Preference) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Performs the given action on each preference in this preference group. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).forEachIndexed(kotlin.Function2)( action: (index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, preference: https://developer.android.com/reference/kotlin/androidx/preference/Preference) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Performs the given action on each preference in this preference group, providing its sequential index. |
| `operator https://developer.android.com/reference/kotlin/androidx/preference/Preference` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).get(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the preference at `index`. |
| `inline operator T?` | `<T : https://developer.android.com/reference/kotlin/androidx/preference/Preference> https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).get(kotlin.CharSequence)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Returns the preference with `key`, or `null` if no preference with `key` is found. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).isEmpty()()` Returns true if this preference group contains no preferences. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).isNotEmpty()()` Returns true if this preference group contains one or more preferences. |
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterator/index.html<https://developer.android.com/reference/kotlin/androidx/preference/Preference>` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).iterator()()` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterator/index.html` over the preferences in this preference group. |
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).minusAssign(androidx.preference.Preference)(preference: https://developer.android.com/reference/kotlin/androidx/preference/Preference)` Removes `preference` from this preference group. |
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).plusAssign(androidx.preference.Preference)(preference: https://developer.android.com/reference/kotlin/androidx/preference/Preference)` Adds `preference` to this preference group. |

| ### Extension properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<https://developer.android.com/reference/kotlin/androidx/preference/Preference>` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).children()` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` over the preferences in this preference group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup.https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup#(androidx.preference.PreferenceGroup).size()` Returns the number of preferences in this preference group. |

| ### Inherited Constants |
|---|
| From [androidx.preference.Preference](https://developer.android.com/reference/kotlin/androidx/preference/Preference) |---|---| | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/Preference#DEFAULT_ORDER() = 2147483647` Specify for `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setOrder(int)` if a specific order is not required. | |

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

## Public constructors

### PreferenceGroup

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

```
PreferenceGroup(context: Context, attrs: AttributeSet?)
```

### PreferenceGroup

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

```
PreferenceGroup(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
```

### PreferenceGroup

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

```
PreferenceGroup(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: Int,
    defStyleRes: Int
)
```

## Public functions

### addItemFromInflater

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

```
fun addItemFromInflater(preference: Preference): Unit
```

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)

```
fun addPreference(preference: Preference): Boolean
```

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

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | 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)

```
fun <T : Preference?> findPreference(key: CharSequence): T?
```

Finds a `https://developer.android.com/reference/kotlin/androidx/preference/Preference` based on its key. If two `https://developer.android.com/reference/kotlin/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/kotlin/androidx/preference/Preference` in any children that are also `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup`s.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | The key of the `https://developer.android.com/reference/kotlin/androidx/preference/Preference` to retrieve |

| Returns |
|---|---|
| `T?` | The `https://developer.android.com/reference/kotlin/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)

```
fun getInitialExpandedChildrenCount(): Int
```

Gets the maximal number of children that are initially shown.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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)

```
fun getPreference(index: Int): Preference
```

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

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the `https://developer.android.com/reference/kotlin/androidx/preference/Preference` to retrieve |

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

### getPreferenceCount

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

```
fun getPreferenceCount(): Int
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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)

```
fun isOrderingAsAdded(): Boolean
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether this group orders based on the order the children are added |

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

### notifyDependencyChange

```
fun notifyDependencyChange(disableDependents: Boolean): Unit
```

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

| Parameters |
|---|---|
| `disableDependents: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether this preference should disable its dependents. |

### onAttached

```
fun onAttached(): Unit
```

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

```
fun onDetached(): Unit
```

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)

```
fun removeAll(): Unit
```

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

### removePreference

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

```
fun removePreference(preference: Preference): Boolean
```

Removes a `https://developer.android.com/reference/kotlin/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/kotlin/androidx/preference/PreferenceGroup#removePreferenceRecursively(java.lang.CharSequence)` to recursively find and remove a preference.

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the preference was found and removed |

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

### removePreferenceRecursively

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

```
fun removePreferenceRecursively(key: CharSequence): Boolean
```

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

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | The key of the preference to remove |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the preference was found and removed |

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

### setInitialExpandedChildrenCount

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

```
fun setInitialExpandedChildrenCount(expandedCount: Int): Unit
```

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 |
|---|---|
| `expandedCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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)

```
fun setOrderingAsAdded(orderingAsAdded: Boolean): Unit
```

Whether to order the `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `orderingAsAdded: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to order according to the order added |

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

## Protected functions

### dispatchRestoreInstanceState

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

```
protected fun dispatchRestoreInstanceState(container: Bundle): Unit
```

Called by `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `container: https://developer.android.com/reference/android/os/Bundle.html` | The Bundle that holds the previously saved state |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` |   |
| `https://developer.android.com/reference/kotlin/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 fun dispatchSaveInstanceState(container: Bundle): Unit
```

Called by `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `container: https://developer.android.com/reference/android/os/Bundle.html` | The Bundle in which to save the instance of this preference |

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

### isOnSameScreenAsChildren

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

```
protected fun isOnSameScreenAsChildren(): Boolean
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `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 fun onPrepareAddPreference(preference: Preference): Boolean
```

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

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to allow adding the preference (`true`), or not (`false`) |

### onRestoreInstanceState

```
protected fun onRestoreInstanceState(state: Parcelable?): Unit
```

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

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

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

### onSaveInstanceState

```
protected fun onSaveInstanceState(): Parcelable
```

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/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/kotlin/androidx/preference/Preference#onRestoreInstanceState(android.os.Parcelable)` |   |
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` |   |

## Extension functions

### PreferenceGroup.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)

```
operator fun PreferenceGroup.contains(preference: Preference): Boolean
```

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

### PreferenceGroup.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)

```
inline fun PreferenceGroup.forEach(action: (preference: Preference) -> Unit): Unit
```

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

### PreferenceGroup.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)

```
inline fun PreferenceGroup.forEachIndexed(
    action: (index: Int, preference: Preference) -> Unit
): Unit
```

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

### PreferenceGroup.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)

```
operator fun PreferenceGroup.get(index: Int): Preference
```

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. |

### PreferenceGroup.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)

```
inline operator fun <T : Preference> PreferenceGroup.get(key: CharSequence): T?
```

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

### PreferenceGroup.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)

```
inline fun PreferenceGroup.isEmpty(): Boolean
```

Returns true if this preference group contains no preferences.

### PreferenceGroup.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)

```
inline fun PreferenceGroup.isNotEmpty(): Boolean
```

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

### PreferenceGroup.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)

```
operator fun PreferenceGroup.iterator(): Iterator<Preference>
```

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

### PreferenceGroup.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)

```
inline operator fun PreferenceGroup.minusAssign(preference: Preference): Unit
```

Removes `preference` from this preference group.

### PreferenceGroup.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)

```
inline operator fun PreferenceGroup.plusAssign(preference: Preference): Unit
```

Adds `preference` to this preference group.

## Extension properties

### PreferenceGroup.children

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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
val PreferenceGroup.children: Sequence<Preference>
```

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

### PreferenceGroup.size

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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
val PreferenceGroup.size: Int
```

Returns the number of preferences in this preference group.