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
Set Activity to Fullscreen Mode in Android - RRutors
Check List for Generate Signed APK Android
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
How to get an image resource by it's name in android?
How to get screen size (width,height) in Android?
What is Android?
How to install/ uninstall apk by command line ADB
How do I generate random numbers in Dart?
How can i comment inside xml file in android studio?
What are the notifications available in android?
What is Application?
What are Android Versions available?
What is the difference between match_parent and fill_parent?
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is NetworkOnMainThread Exception?
What is the Different Between val and var in Kotlin?
What is "shared preferences" in Android ?
What is Intent? What is the difference between an implicit intent and an explicit intent?
What happens next when the device switches between portrait and landscape?
How to save activity State in Android?
How to Get bitmap from drawable: Android
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to convert DP to Pixel and Pixel to Dp?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
Extract Date and Time from Long Type Variable - RRutors
Explain Fragment Life Cycle
How to Generate signed apk with android studio
How to convert milli seconds to hours, minutes and seconds in Android?
How to find Android Device UDID or unique ID?
How to get complete address from latitude and longitude?
Decompile APK Files: How to Get Source Code - RRutors Guide
Fix Play Store Rejection Due to SMS Permission - RRutors
Android Studio project R can't find
How to start a new activity on button click
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Permission denied for window type 2010 in Marshmallow device
How To Set Text Color Programmatically Android TextView?
How to get a contact image using a phone number in android?
Hide/Disable soft keyboard on Activity launch: Android
How to Use Deprecated Handler() in Android - RRutors Guide