Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

ViewModelStores

open class ViewModelStores
kotlin.Any
   ↳ androidx.lifecycle.ViewModelStores

Factory methods for ViewModelStore class.

Summary

Public methods

open static ViewModelStore
of(@NonNull activity: FragmentActivity)

Returns the ViewModelStore of the given activity.

open static ViewModelStore
of(@NonNull fragment: Fragment)

Returns the ViewModelStore of the given fragment.

Public methods

of

@NonNull @MainThread open static fun of(@NonNull activity: FragmentActivity): ViewModelStore

Deprecated: Use FragmentActivity#getViewModelStore()

Returns the ViewModelStore of the given activity.

Parameters
activity FragmentActivity: an activity whose ViewModelStore is requested
Return
ViewModelStore: a ViewModelStore

of

@NonNull @MainThread open static fun of(@NonNull fragment: Fragment): ViewModelStore

Deprecated: Use Fragment#getViewModelStore()

Returns the ViewModelStore of the given fragment.

Parameters
fragment Fragment: a fragment whose ViewModelStore is requested
Return
ViewModelStore: a ViewModelStore