Overview - Why ViewModel survives configuration changes
What is it?
A ViewModel is a special component in Android apps that holds and manages UI-related data. It is designed to survive configuration changes like screen rotations, so the data stays intact. This means the app does not lose important information or restart processes when the device changes orientation or other settings.
Why it matters
Without ViewModel, every time the screen rotates or a configuration changes, the app would lose its current data and state, causing a poor user experience. Users would see resets, lost inputs, or delays. ViewModel solves this by keeping data alive across these changes, making apps feel smooth and reliable.
Where it fits
Before learning this, you should understand Android app components like Activities and Fragments and how configuration changes affect them. After this, you can learn about LiveData, data binding, and advanced state management techniques to build robust apps.