The ViewModel is designed to be tied to the lifecycle of an Activity or Fragment but is retained when configuration changes happen. This means the system keeps the same ViewModel instance alive, so data is preserved without needing to save and restore manually.
ViewModel survives configuration changes like rotation, so any data stored in it remains available and does not get lost.
The ViewModel is destroyed only when the lifecycle owner is permanently finished, such as when the Activity is closed, not during temporary configuration changes.
When ViewModel is scoped to the parent Activity, all fragments within that Activity share the same ViewModel instance, preserving data across fragment navigation.
When you use 'this' inside an Activity, it refers to the current Activity instance. After rotation, the Activity is recreated, so a new ViewModelProvider is created, resulting in a new ViewModel instance. To retain data, you must use the same lifecycle owner or use ViewModelProvider tied to a persistent owner.