From the course: Android Development Essential Training: 3 Navigation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Explore ViewModels and LiveData

Explore ViewModels and LiveData - Android Tutorial

From the course: Android Development Essential Training: 3 Navigation

Start my 1-month free trial

Explore ViewModels and LiveData

- [Presenter] If you recall, the Android framework manages the life cycles of activities and fragments. It may decide to destroy or recreate them in response to certain user actions or device events, that are completely outside of your control. This is where ViewModels come into the picture. They allow you to store and manage UI data in a life cycle-conscious way. They're retained during configuration changes. This means that you won't have to worry about losing your UI related data when the framework chooses to destroy or recreate your components. And finally, ViewModels offer a more efficient way to handle asynchronous calls. They were designed to take the burden of managing these calls and their subsequent cleanup out of the hands of our UI controllers. A ViewModel is scoped to the life cycle associated with its creation. In this example, the ViewModel is associated with an activity. When the activity is first…

Contents