ViewModelStore


public class ViewModelStore


Class to store ViewModels.

Instances of ViewModelStore must be retained through configuration changes. If the owner of a ViewModelStore, typically a `ViewModelStoreOwner`, is destroyed and recreated due to a configuration change, the new owner must have the old instance of the ViewModelStore.

If the owner of a ViewModelStore is destroyed and is not going to be recreated, it should call `clear` on this ViewModelStore so that The ViewModels stored by it are notified that they are no longer needed.

Use `ViewModelStoreOwner.getViewModelStore` to retrieve a ViewModelStore for activities and fragments.

Summary

Public constructors

Public methods

final void

Clears internal storage and notifies ViewModels that they are no longer used.

Public constructors

ViewModelStore

Added in 2.0.0
public ViewModelStore()

Public methods

clear

Added in 2.0.0
public final void clear()

Clears internal storage and notifies ViewModels that they are no longer used.