# SavedStateRegistryOwner

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

*** ** * ** ***


```
public interface SavedStateRegistryOwner extends LifecycleOwner
```

<br />

Known direct subclasses [ComponentActivity](https://developer.android.com/reference/androidx/activity/ComponentActivity), [ComponentDialog](https://developer.android.com/reference/androidx/activity/ComponentDialog), [Fragment](https://developer.android.com/reference/androidx/fragment/app/Fragment), [NavBackStackEntry](https://developer.android.com/reference/androidx/navigation/NavBackStackEntry)

|---|---|
| `https://developer.android.com/reference/androidx/activity/ComponentActivity` | Base class for activities that enables composition of higher level components. |
| `https://developer.android.com/reference/androidx/activity/ComponentDialog` | Base class for dialogs that enables composition of higher level components. |
| `https://developer.android.com/reference/androidx/fragment/app/Fragment` | Static library support version of the framework's `https://developer.android.com/reference/android/app/Fragment.html`. |
| `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` | Representation of an entry in the back stack of a `https://developer.android.com/reference/androidx/navigation/NavController`. |

Known indirect subclasses [AbstractListDetailFragment](https://developer.android.com/reference/androidx/navigation/fragment/AbstractListDetailFragment), [AbstractProgressFragment](https://developer.android.com/reference/androidx/navigation/dynamicfeatures/fragment/ui/AbstractProgressFragment), [AlertDialog](https://developer.android.com/reference/androidx/appcompat/app/AlertDialog), [AmbientModeSupport](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport), [AppCompatActivity](https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity), [AppCompatDialogFragment](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDialogFragment), [AppCompatDialog](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDialog), [BaseCarAppActivity](https://developer.android.com/reference/androidx/car/app/activity/BaseCarAppActivity), [BaseLeanbackPreferenceFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragmentCompat), [BaseSupportFragment](https://developer.android.com/reference/androidx/leanback/app/BaseSupportFragment), [BrandedSupportFragment](https://developer.android.com/reference/androidx/leanback/app/BrandedSupportFragment), [BrowseSupportFragment](https://developer.android.com/reference/androidx/leanback/app/BrowseSupportFragment), [CarAppActivity](https://developer.android.com/reference/androidx/car/app/activity/CarAppActivity), [DefaultProgressFragment](https://developer.android.com/reference/androidx/navigation/dynamicfeatures/fragment/ui/DefaultProgressFragment), [DetailsSupportFragment](https://developer.android.com/reference/androidx/leanback/app/DetailsSupportFragment), [DialogFragment](https://developer.android.com/reference/androidx/fragment/app/DialogFragment), [DynamicNavHostFragment](https://developer.android.com/reference/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment), [EditTextPreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/preference/EditTextPreferenceDialogFragmentCompat), [EditablePdfViewerFragment](https://developer.android.com/reference/androidx/pdf/ink/EditablePdfViewerFragment), [ErrorSupportFragment](https://developer.android.com/reference/androidx/leanback/app/ErrorSupportFragment), [FragmentActivity](https://developer.android.com/reference/androidx/fragment/app/FragmentActivity), [GuidedStepSupportFragment](https://developer.android.com/reference/androidx/leanback/app/GuidedStepSupportFragment), [HeadersSupportFragment](https://developer.android.com/reference/androidx/leanback/app/HeadersSupportFragment), [LauncherActivity](https://developer.android.com/reference/androidx/car/app/activity/LauncherActivity), [LeanbackEditTextPreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/LeanbackEditTextPreferenceDialogFragmentCompat), [LeanbackListPreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/LeanbackListPreferenceDialogFragmentCompat), [LeanbackPreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceDialogFragmentCompat), [LeanbackPreferenceFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragmentCompat), [LeanbackSettingsFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/LeanbackSettingsFragmentCompat), [ListFragment](https://developer.android.com/reference/androidx/fragment/app/ListFragment), [ListPreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/preference/ListPreferenceDialogFragmentCompat), [MediaRouteChooserDialogFragment](https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteChooserDialogFragment), [MediaRouteChooserDialog](https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteChooserDialog), [MediaRouteControllerDialogFragment](https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteControllerDialogFragment), [MediaRouteControllerDialog](https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteControllerDialog), [MediaRouteDiscoveryFragment](https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteDiscoveryFragment), [MultiSelectListPreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/preference/MultiSelectListPreferenceDialogFragmentCompat), [NavHostFragment](https://developer.android.com/reference/androidx/navigation/fragment/NavHostFragment), [OnboardingSupportFragment](https://developer.android.com/reference/androidx/leanback/app/OnboardingSupportFragment), [PdfViewerFragment](https://developer.android.com/reference/androidx/pdf/viewer/fragment/PdfViewerFragment), [PlaybackSupportFragment](https://developer.android.com/reference/androidx/leanback/app/PlaybackSupportFragment), [PreferenceDialogFragmentCompat](https://developer.android.com/reference/androidx/preference/PreferenceDialogFragmentCompat), [PreferenceFragmentCompat](https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat), [PreferenceHeaderFragmentCompat](https://developer.android.com/reference/androidx/preference/PreferenceHeaderFragmentCompat), [RowsSupportFragment](https://developer.android.com/reference/androidx/leanback/app/RowsSupportFragment), [SearchSupportFragment](https://developer.android.com/reference/androidx/leanback/app/SearchSupportFragment), [VerticalGridSupportFragment](https://developer.android.com/reference/androidx/leanback/app/VerticalGridSupportFragment), [VideoSupportFragment](https://developer.android.com/reference/androidx/leanback/app/VideoSupportFragment)

|---|---|
| `https://developer.android.com/reference/androidx/navigation/fragment/AbstractListDetailFragment` | A fragment supports adaptive two-pane layout. |
| `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/fragment/ui/AbstractProgressFragment` | The base class for `https://developer.android.com/reference/androidx/fragment/app/Fragment`s that handle dynamic feature installation. |
| `https://developer.android.com/reference/androidx/appcompat/app/AlertDialog` | A subclass of Dialog that can display one, two or three buttons. |
| `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport` | **This class is deprecated.** Use `https://developer.android.com/reference/androidx/wear/ambient/AmbientLifecycleObserver` instead. <br /> |
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity` | Base class for activities that wish to use some of the newer platform features on older Android devices. |
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDialogFragment` | A special version of `https://developer.android.com/reference/androidx/fragment/app/DialogFragment` which uses an `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDialog` in place of a platform-styled dialog. |
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDialog` | Base class for AppCompat themed `https://developer.android.com/reference/android/app/Dialog.html`s. |
| `https://developer.android.com/reference/androidx/car/app/activity/BaseCarAppActivity` | Core logic for CarAppLibrary Activity interaction with a host. |
| `https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragmentCompat` | This fragment provides a preference fragment with leanback-style behavior, suitable for embedding into broader UI elements. |
| `https://developer.android.com/reference/androidx/leanback/app/BaseSupportFragment` | Base class for leanback Fragments. |
| `https://developer.android.com/reference/androidx/leanback/app/BrandedSupportFragment` | Fragment class for managing search and branding using a view that implements `https://developer.android.com/reference/androidx/leanback/widget/TitleViewAdapter.Provider`. |
| `https://developer.android.com/reference/androidx/leanback/app/BrowseSupportFragment` | A fragment for creating Leanback browse screens. |
| `https://developer.android.com/reference/androidx/car/app/activity/CarAppActivity` | The class representing a car app activity in the main display. |
| `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/fragment/ui/DefaultProgressFragment` | The default `https://developer.android.com/reference/androidx/fragment/app/Fragment` to display during installation progress. |
| `https://developer.android.com/reference/androidx/leanback/app/DetailsSupportFragment` | A fragment for creating Leanback details screens. |
| `https://developer.android.com/reference/androidx/fragment/app/DialogFragment` | A fragment that displays a dialog window, floating in the foreground of its activity's window. |
| `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/fragment/DynamicNavHostFragment` | The `https://developer.android.com/reference/androidx/navigation/fragment/NavHostFragment` for dynamic features. |
| `https://developer.android.com/reference/androidx/preference/EditTextPreferenceDialogFragmentCompat` |   |
| `https://developer.android.com/reference/androidx/pdf/ink/EditablePdfViewerFragment` | A `https://developer.android.com/reference/androidx/fragment/app/Fragment` that extends `https://developer.android.com/reference/androidx/pdf/viewer/fragment/PdfViewerFragment` to provide PDF editing capabilities, including annotation and form filling, leveraging the 'androidx.ink' library. |
| `https://developer.android.com/reference/androidx/leanback/app/ErrorSupportFragment` | A fragment for displaying an error indication. |
| `https://developer.android.com/reference/androidx/fragment/app/FragmentActivity` | Base class for activities that want to use the support-based `https://developer.android.com/reference/androidx/fragment/app/Fragment`. |
| `https://developer.android.com/reference/androidx/leanback/app/GuidedStepSupportFragment` | A GuidedStepSupportFragment is used to guide the user through a decision or series of decisions. |
| `https://developer.android.com/reference/androidx/leanback/app/HeadersSupportFragment` | An fragment containing a list of row headers. |
| `https://developer.android.com/reference/androidx/car/app/activity/LauncherActivity` | This class handles providing the right launcher activity when running native applications and Car App Library applications. |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackEditTextPreferenceDialogFragmentCompat` | Implemented a dialog to input text. |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackListPreferenceDialogFragmentCompat` | Implemented a dialog to show `https://developer.android.com/reference/androidx/preference/ListPreference` or `https://developer.android.com/reference/androidx/preference/MultiSelectListPreference`. |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceDialogFragmentCompat` | A fragment that shows `https://developer.android.com/reference/androidx/preference/DialogPreference`, for example `https://developer.android.com/reference/androidx/preference/ListPreference` or `https://developer.android.com/reference/androidx/preference/MultiSelectListPreference`. |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragmentCompat` | This fragment provides a fully decorated leanback-style preference fragment, including a list background and header. |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackSettingsFragmentCompat` | This fragment provides a container for displaying a `https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragmentCompat` |
| `https://developer.android.com/reference/androidx/fragment/app/ListFragment` | Static library support version of the framework's `https://developer.android.com/reference/android/app/ListFragment.html`. |
| `https://developer.android.com/reference/androidx/preference/ListPreferenceDialogFragmentCompat` |   |
| `https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteChooserDialogFragment` | Media route chooser dialog fragment. |
| `https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteChooserDialog` | This class implements the route chooser dialog for `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter`. |
| `https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteControllerDialogFragment` | Media route controller dialog fragment. |
| `https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteControllerDialog` | This class implements the route controller dialog for `https://developer.android.com/reference/androidx/mediarouter/media/MediaRouter`. |
| `https://developer.android.com/reference/androidx/mediarouter/app/MediaRouteDiscoveryFragment` | Media route discovery fragment. |
| `https://developer.android.com/reference/androidx/preference/MultiSelectListPreferenceDialogFragmentCompat` |   |
| `https://developer.android.com/reference/androidx/navigation/fragment/NavHostFragment` | NavHostFragment provides an area within your layout for self-contained navigation to occur. |
| `https://developer.android.com/reference/androidx/leanback/app/OnboardingSupportFragment` | An OnboardingSupportFragment provides a common and simple way to build onboarding screen for applications. |
| `https://developer.android.com/reference/androidx/pdf/viewer/fragment/PdfViewerFragment` | A Fragment that renders a PDF document. |
| `https://developer.android.com/reference/androidx/leanback/app/PlaybackSupportFragment` | A fragment for displaying playback controls and related content. |
| `https://developer.android.com/reference/androidx/preference/PreferenceDialogFragmentCompat` | Abstract base class which presents a dialog associated with a `https://developer.android.com/reference/androidx/preference/DialogPreference`. |
| `https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat` | A PreferenceFragmentCompat is the entry point to using the Preference library. |
| `https://developer.android.com/reference/androidx/preference/PreferenceHeaderFragmentCompat` | `https://developer.android.com/reference/androidx/preference/PreferenceHeaderFragmentCompat` implements a two-pane fragment for preferences. |
| `https://developer.android.com/reference/androidx/leanback/app/RowsSupportFragment` | An ordered set of rows of leanback widgets. |
| `https://developer.android.com/reference/androidx/leanback/app/SearchSupportFragment` | A fragment to handle searches. |
| `https://developer.android.com/reference/androidx/leanback/app/VerticalGridSupportFragment` | A fragment for creating leanback vertical grids. |
| `https://developer.android.com/reference/androidx/leanback/app/VideoSupportFragment` | Subclass of `https://developer.android.com/reference/androidx/leanback/app/PlaybackSupportFragment` that is responsible for providing a `https://developer.android.com/reference/android/view/SurfaceView.html` and rendering video. |

*** ** * ** ***

A scope that owns a `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry`.

Pass this owner to create a `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryController` through which the owner accesses and performs operations on its `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry`.

The typical lifecycle flow and method call sequence of these components is:

```
Lifecycle.State                 SavedStateRegistryController
---                 ---
INITIALIZED ---> performAttach
                                |
                                performRestore
                                |
CREATED ---+
                                |
STARTED ---> (register providers, consume state)
                                |
CREATED ---> performSave
                                |
DESTROYED <---+
```

`https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryController#performAttach()` must be called once (and only once) on the main thread during the owner's `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#INITIALIZED` state. Call it before calling `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryController#performRestore(androidx.savedstate.SavedState)`.

`https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryController#performRestore(androidx.savedstate.SavedState)` can be called with a nullable if nothing needs to be restored, or with the saved state to be restored. Call it in one of two places:

1. Directly before the `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` moves to `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#CREATED`.

2. Before `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#STARTED` is reached, as part of the `https://developer.android.com/reference/androidx/lifecycle/LifecycleObserver` added during owner initialization.

`https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryController#performSave(androidx.savedstate.SavedState)` should be called after the owner has been stopped but before it reaches `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#DESTROYED` state. Call it only once the owner has received the `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_STOP` event. The saved state passed to performSave will be the saved state restored by performRestore.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` | `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner#getSavedStateRegistry()()` The `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` owned by this `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`. |

| ### Extension functions |
|---|---|
| `default final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread <T extends https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner & https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner> https://developer.android.com/reference/androidx/savedstate/SavedStateHandleSupport.https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner#(androidx.savedstate.SavedStateRegistryOwner).enableSavedStateHandles()( @https://developer.android.com/reference/androidx/annotation/NonNull T receiver )` Enables support for `https://developer.android.com/reference/androidx/lifecycle/SavedStateHandle` in a component. |
| `default final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.properties/-read-write-property/index.html<https://developer.android.com/reference/java/lang/Object.html, @https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwnerDelegateKt.https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner#(androidx.savedstate.SavedStateRegistryOwner).saved(kotlin.String,androidx.savedstate.serialization.SavedStateConfiguration,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner receiver, https://developer.android.com/reference/java/lang/String.html key, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration configuration, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> init )` Returns a property delegate that manages the saving and restoring of a value of type `https://developer.android.com/reference/androidx/savedstate/serialization/package-summary#(androidx.savedstate.SavedStateRegistryOwner).saved(kotlin.String,androidx.savedstate.serialization.SavedStateConfiguration,kotlin.Function0)` within the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` of this `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`. |
| `default final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.properties/-read-write-property/index.html<https://developer.android.com/reference/java/lang/Object.html, @https://developer.android.com/reference/androidx/annotation/NonNull T>` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwnerDelegateKt.https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner#(androidx.savedstate.SavedStateRegistryOwner).saved(kotlinx.serialization.KSerializer,kotlin.String,androidx.savedstate.serialization.SavedStateConfiguration,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-k-serializer/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> serializer, https://developer.android.com/reference/java/lang/String.html key, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration configuration, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> init )` Returns a property delegate that manages the saving and restoring of a value of type `https://developer.android.com/reference/androidx/savedstate/serialization/package-summary#(androidx.savedstate.SavedStateRegistryOwner).saved(kotlinx.serialization.KSerializer,kotlin.String,androidx.savedstate.serialization.SavedStateConfiguration,kotlin.Function0)` within the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` of this `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`. |

### Inherited methods

From [androidx.lifecycle.LifecycleOwner](https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner) `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/Lifecycle` `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner#getLifecycle()()`

The `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` of this owner.

## Public methods

### getSavedStateRegistry

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

```
abstract @NonNull SavedStateRegistry getSavedStateRegistry()
```

The `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` owned by this `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`.

## Extension functions

### SavedStateHandleSupport.enableSavedStateHandles

Artifact: [androidx.lifecycle:lifecycle-viewmodel-savedstate](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/SavedStateHandleSupport.kt+function:enableSavedStateHandles)

```
@MainThread
default final void <T extends SavedStateRegistryOwner & ViewModelStoreOwner> SavedStateHandleSupport.enableSavedStateHandles(
    @NonNull T receiver
)
```

Enables support for `https://developer.android.com/reference/androidx/lifecycle/SavedStateHandle` in a component.

After calling this method, `https://developer.android.com/reference/androidx/lifecycle/package-summary#(androidx.lifecycle.viewmodel.CreationExtras).createSavedStateHandle()` can be invoked on `https://developer.android.com/reference/androidx/lifecycle/viewmodel/CreationExtras` containing the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner` and `https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner`.

This must be called while the component is in the `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#INITIALIZED` or `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#CREATED` state, and before requesting any `https://developer.android.com/reference/androidx/lifecycle/ViewModel` that requires a `https://developer.android.com/reference/androidx/lifecycle/SavedStateHandle`.

### SavedStateRegistryOwnerDelegateKt.saved

Artifact: [androidx.savedstate:savedstate](https://developer.android.com/jetpack/androidx/releases/savedstate) [View Source](https://cs.android.com/search?q=file:androidx/savedstate/serialization/SavedStateRegistryOwnerDelegate.kt+function:saved)

```
default final @NonNull ReadWriteProperty<Object, @NonNull T> <T extends Object> SavedStateRegistryOwnerDelegateKt.saved(
    @NonNull SavedStateRegistryOwner receiver,
    String key,
    @NonNull SavedStateConfiguration configuration,
    @NonNull Function0<@NonNull T> init
)
```

Returns a property delegate that manages the saving and restoring of a value of type `https://developer.android.com/reference/androidx/savedstate/serialization/package-summary#(androidx.savedstate.SavedStateRegistryOwner).saved(kotlin.String,androidx.savedstate.serialization.SavedStateConfiguration,kotlin.Function0)` within the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` of this `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`.

```kotlin
import androidx.activity.ComponentActivity

@Serializable data class User(val id: Int, val name: String)
class MyActivity : ComponentActivity() {
    val user by saved(key = "myKey") { User(id = 123, name = "John Doe") }
}
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html key` | An optional `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` key to use for storing the value in the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry`. A default key will be generated if it's omitted or when 'null' is passed. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration configuration` | The `https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration` to use. Defaults to `https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration#DEFAULT()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> init` | The function to provide the initial value of the property. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.properties/-read-write-property/index.html<https://developer.android.com/reference/java/lang/Object.html, @https://developer.android.com/reference/androidx/annotation/NonNull T>` | A property delegate provider that manages the saving and restoring of the value. |

### SavedStateRegistryOwnerDelegateKt.saved

Artifact: [androidx.savedstate:savedstate](https://developer.android.com/jetpack/androidx/releases/savedstate) [View Source](https://cs.android.com/search?q=file:androidx/savedstate/serialization/SavedStateRegistryOwnerDelegate.kt+function:saved)

```
default final @NonNull ReadWriteProperty<Object, @NonNull T> <T extends Object> SavedStateRegistryOwnerDelegateKt.saved(
    @NonNull SavedStateRegistryOwner receiver,
    @NonNull KSerializer<@NonNull T> serializer,
    String key,
    @NonNull SavedStateConfiguration configuration,
    @NonNull Function0<@NonNull T> init
)
```

Returns a property delegate that manages the saving and restoring of a value of type `https://developer.android.com/reference/androidx/savedstate/serialization/package-summary#(androidx.savedstate.SavedStateRegistryOwner).saved(kotlinx.serialization.KSerializer,kotlin.String,androidx.savedstate.serialization.SavedStateConfiguration,kotlin.Function0)` within the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` of this `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner`.

```kotlin
import androidx.activity.ComponentActivity

@Serializable data class User(val id: Int, val name: String)
class MyActivity : ComponentActivity() {
    val user by
        saved(key = "myKey", serializer = serializer()) { User(id = 123, name = "John Doe") }
}
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-k-serializer/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> serializer` | The `https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-k-serializer/index.html` to use for serializing and deserializing the value. |
| `https://developer.android.com/reference/java/lang/String.html key` | An optional `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` key to use for storing the value in the `https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry`. A default key will be generated if it's omitted or when 'null' is passed. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration configuration` | The `https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration` to use. Defaults to `https://developer.android.com/reference/androidx/savedstate/serialization/SavedStateConfiguration#DEFAULT()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull T> init` | The function to provide the initial value of the property. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.properties/-read-write-property/index.html<https://developer.android.com/reference/java/lang/Object.html, @https://developer.android.com/reference/androidx/annotation/NonNull T>` | A property delegate provider that manages the saving and restoring of the value. |