Sign in Go Pro

Android Architecture Components - A Deep Dive

Why We Need a ViewModel component

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

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

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Android Architecture Components - A Deep Dive