Android Architecture Components - A Deep Dive
Why We Need a ViewModel component
Up next
Previous
About
Most of us unknowingly put everything into the UI components like Activity and Fragment ranging from into database operations to networking related code which makes the Activity a "God activity" and as these UI components have their own lifecycle; controlled by the framework. Hence during a configuration change, our data is lost while the UI is re-created which leads to memory leaks and even app crashes.
ViewModels are here to change this, they are containers which hold the data required by the UI components which enables our data to survive the configuration change.
In this lesson, you'll learn what's the problem with "God activity" and how placing everything in Activity and later see why there was a need of ViewModel help us solve these problems.
Instructor
Links
Comments
Lessons in Android Architecture Components - A Deep Dive


















