# ViewTreeSavedStateRegistryOwner

Added in 1.1.0

*** ** * ** ***


```
public final class ViewTreeSavedStateRegistryOwner
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` | `https://developer.android.com/reference/androidx/savedstate/ViewTreeSavedStateRegistryOwner#(android.view.View).get()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Retrieve the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` responsible for managing the saved state for this `https://developer.android.com/reference/android/view/View.html`. |
| `static final void` | `https://developer.android.com/reference/androidx/savedstate/ViewTreeSavedStateRegistryOwner#(android.view.View).set(androidx.savedstate.SavedStateRegistryOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner owner)` Set the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` responsible for managing the saved state for this `https://developer.android.com/reference/android/view/View.html` Calls to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/index.html` from this view or descendants will return `owner`. |

## Public methods

### get

Artifact: [androidx.savedstate:savedstate](https://developer.android.com/jetpack/androidx/releases/savedstate) [View Source](https://cs.android.com/search?q=file:androidx/savedstate/ViewTreeSavedStateRegistryOwner.android.kt+function:findViewTreeSavedStateRegistryOwner) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/savedstate#1.1.0)

```
public static final SavedStateRegistryOwner get(@NonNull View receiver)
```

Retrieve the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` responsible for managing the saved state for this `https://developer.android.com/reference/android/view/View.html`. This may be used to save or restore the state associated with the view.

The returned `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` is managing all the Views within the Fragment or Activity this `https://developer.android.com/reference/android/view/View.html` is added to.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` | The `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` responsible for managing the saved state for this view and/or some subset of its ancestors |

### set

Artifact: [androidx.savedstate:savedstate](https://developer.android.com/jetpack/androidx/releases/savedstate) [View Source](https://cs.android.com/search?q=file:androidx/savedstate/ViewTreeSavedStateRegistryOwner.android.kt+function:setViewTreeSavedStateRegistryOwner) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/savedstate#1.1.0)

```
public static final void set(@NonNull View receiver, SavedStateRegistryOwner owner)
```

Set the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` responsible for managing the saved state for this `https://developer.android.com/reference/android/view/View.html` Calls to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/index.html` from this view or descendants will return `owner`.

This is is automatically set for you in the common cases of using fragments or ComponentActivity.

This should only be called by constructs such as activities or fragments that manage a view tree and their saved state through a `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`. Callers should only set a `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` that will be *stable.* The associated `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` should be cleared if the view tree is removed and is not guaranteed to later become reattached to a window.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner owner` | The `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` responsible for managing the saved state for the given view |