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
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How to save activity State in Android?
How to get a contact image using a phone number in android?
How do i load image from drawable folder in Jetpack Compose?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
What is "shared preferences" in Android ?
How can i comment inside xml file in android studio?
Add Jar/Library Files as Dependency in Android Studio
What is NetworkOnMainThread Exception?
How to convert milli seconds to hours, minutes and seconds in Android?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
Hide/Disable soft keyboard on Activity launch: Android
How do I check in SQLite whether a table exists?
Emulator: emulator: ERROR: Can't find 'Linux version ' string in kernel image file: Andr
What is the difference between match_parent and fill_parent?
How to find Android Device UDID or unique ID?
What are the notifications available in android?
Set Activity to Fullscreen Mode in Android - RRutors
How to get an image resource by it's name in android?
What is Android?
What is ANR in android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to reduce APK package size?
How to Get bitmap from drawable: Android
How to stop EditText focus at Activity startup in Android?
How To Set Text Color Programmatically Android TextView?
Fix Android Emulator Kill Error When Running Your App
What is Application?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to get complete address from latitude and longitude?
How to get screen size (width,height) in Android?
What is the Different Between val and var in Kotlin?
Open PDF in Google Drive with Intent in Android - RRutors
How to Exit android app on back pressed?
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to check Android version?
Permission denied for window type 2010 in Marshmallow device
How to start a new activity on button click
What are Android Versions available?
Explain Fragment Life Cycle