Skip to content

Instantly share code, notes, and snippets.


Oscar Struka9

View GitHub Profile

The Gentle Guide to ViewModel

Hello, guys, I had so much fun writing my previous article about LiveData that I started to think about the next one right away, the obvious choice for the topic was the next component of the Android Architecture Components framework so I thought about making it a series where we will cover all of them, so this is the second part of the series where we will talk about ViewModel


ViewModel is a class that has been designed with the single goal of storing data that is related to the UI in a lifecycle aware manner, it’s implemented in such a way that it outlives any configuration change, such as device rotation.

Why do we even need it?

Android Framework handles the lifecycle of ::Activities:: and ::Fragments::, which from now on we will refer to i