tezvyn:

What is a ViewModel and what lifecycle problem does it solve?

Source: developer.android.combeginner

Tests config-change survival: ViewModel outlives Activity recreation so state survives rotation. Strong answer notes it holds non-serializable data and separates concerns, but does not survive process death.

Tests your understanding of the Android configuration-change lifecycle and proper state ownership. A strong answer explains that ViewModel is scoped to the screen's lifecycle (via ViewModelStoreOwner), not the Activity instance, so it survives rotation while the Activity is destroyed and recreated. It holds non-serializable UI state and heavy objects like network results, separating business logic from the UI controller.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

What is a ViewModel and what lifecycle problem does it solve? · Tezvyn