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
What are the notifications available in android?
FCM Not Receiving Notifications in Android - RRutors
How to Generate signed apk with android studio
How do i load image from drawable folder in Jetpack Compose?
How to install/ uninstall apk by command line ADB
What is Intent? What is the difference between an implicit intent and an explicit intent?
How to validate email address in Android with Kotlin?
How do I generate random numbers in Dart?
Hide/Disable soft keyboard on Activity launch: Android
How to convert DP to Pixel and Pixel to Dp?
Fix Play Store Rejection Due to SMS Permission - RRutors
Symmetric vs Asymmetric Encryption in Android Server - RRutors
How to convert milli seconds to hours, minutes and seconds in Android?
What happens next when the device switches between portrait and landscape?
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Decompile APK Files: How to Get Source Code - RRutors Guide
Explain Fragment Life Cycle
How to get an image resource by it's name in android?
How to reduce APK package size?
How To Set Text Color Programmatically Android TextView?
What is ANR? How to avoid and resolve it?
How to stop EditText focus at Activity startup in Android?
Key Points to remember while develop the Android Application.
How do I check in SQLite whether a table exists?
What is the difference between match_parent and fill_parent?
Android Studio project R can't find
What is Application?
Fix Android Emulator Kill Error When Running Your App
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to check Android version?
What are Android Versions available?
How to save activity State in Android?
What is Context?
How to Use Deprecated Handler() in Android - RRutors Guide
How can i comment inside xml file in android studio?
Open PDF in Google Drive with Intent in Android - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
Extract Date and Time from Long Type Variable - RRutors
What is Android?