Before Architecture Components we were used to save the UI state by onSaveInstanceState() method SaveInstanceState: We need to override onSaveInstanceState(Bundle savedInstanceState) and store the application state values in the form of bundle @Override savedInstanceState.putBoolean("mybool", true); } Saved instanceState could save only parceble data. ViewModel ViewModel instance is part of Applications process and hence it is able to handle configuration changes.
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("myint", 1);
savedInstanceState.putString("mystring", "Back to Activity State");
This have limit to staore small amount of parceble data
If process dies, ViewModel instance lost and all the saved state will also be lost.
It will work for large objects also.
Don't have any restritions to save the state.
You can read about Viewmodel here
Check List for Generate Signed APK Android
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
What are the notifications available in android?
What is Application?
What is Context?
How to copy database from assets folder in android using kotlin
How to Get bitmap from drawable: Android
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is the difference between match_parent and fill_parent?
ERROR Android emulator gets killed when I try to run my application and choose an emulator it ret
How to find Android Device UDID or unique ID?
How to stop EditText focus at Activity startup in Android?
Explain Fragment Life Cycle
What is Android Fragments?
How can i comment inside xml file in android studio?
How To Set Text Color Programmatically Android TextView?
What is the Different Between val and var in Kotlin?
What is Intent? What is the difference between an implicit intent and an explicit intent?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path
How to Generate signed apk with android studio
What is Android?
What are Android Versions available?
How to get complete address from latitude and longitude?
How to validate email address in Android with Kotlin?
What is NetworkOnMainThread Exception?
How to convert DP to Pixel and Pixel to Dp?
How to avoid multiple button click at same time in android?
How to convert milli seconds to hours, minutes and seconds in Android?
How to get screen size (width,height) in Android?
How to save activity State in Android?
Android FCM not receiving notifications when app is removed from background
Key Points to remember while develop the Android Application.
How to add jar/library files as a dependency in Android studio gradle file
Duplicate files during packaging of APK” build.gradle issue: Android Studio
How do I check in SQLite whether a table exists?
Android Studio project R can't find
What is ANR? How to avoid and resolve it?
How to Exit android app on back pressed?