Overview - ViewModel creation
What is it?
A ViewModel is a special class in Android apps that holds and manages UI-related data. It keeps this data safe even when the screen rotates or the app changes state. Creating a ViewModel means making this class to store and handle data separately from the screen itself.
Why it matters
Without ViewModels, data would be lost every time the screen changes, like rotating the phone. This would make apps feel slow and frustrating because they would reload or lose what the user was doing. ViewModels solve this by keeping data alive and ready, making apps smooth and reliable.
Where it fits
Before learning ViewModel creation, you should understand basic Android app structure and Kotlin classes. After this, you can learn about LiveData and data binding to connect ViewModels to the user interface.