androidx.lifecycle:lifecycle-viewmodel

Official Description: Android Lifecycle ViewModel

CommonsWare’s Notes

As the name suggests, this artifact contains ViewModel, the Jetpack solution for retaining data across configuration changes. Despite its name, ViewModel is not strictly tied to MVVM or other GUI architectures that use “viewmodel” as a term.

This artifact also contains ViewModelProvider and ViewModelStore, ways for you to obtain ViewModel instances. It also contains AndroidViewModel, a ViewModel that has a Context that you can use for all those places where you need a Context.

As with many facet of the Jetpack, ViewModel was introduced before the migration to androidx Java packages. If you see references to android.arch.lifecycle.ViewModel, the AndroidX equivalent has a near-identical API and fills the same role.

Documentation

Knowledge

Samples

Versions