0
0
Android Kotlinmobile~5 mins

Saving instance state in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of saving instance state in Android?
Saving instance state helps preserve UI data and user inputs when the app is temporarily stopped or rotated, so the user doesn't lose their progress.
Click to reveal answer
beginner
Which Android lifecycle method is used to save instance state?
The onSaveInstanceState() method is called to save data before the activity might be destroyed.
Click to reveal answer
beginner
How do you restore saved instance state in an Android activity?
You restore saved data in onCreate() or onRestoreInstanceState() by reading from the Bundle passed as a parameter.
Click to reveal answer
intermediate
What kind of data should you save in the instance state Bundle?
Save small, simple UI-related data like text inputs, scroll positions, or selected items. Avoid saving large or complex objects.
Click to reveal answer
beginner
True or False: The instance state Bundle is saved permanently on the device.
False. The instance state Bundle is temporary and only used to restore UI state during short-term interruptions like rotation or backgrounding.
Click to reveal answer
Which method is called to save UI state before an activity is destroyed?
AonPause()
BonSaveInstanceState()
ConDestroy()
DonStart()
Where do you typically restore saved instance state data?
AonCreate() or onRestoreInstanceState()
BonStop()
ConResume()
DonDestroy()
What type of data is best to save in the instance state Bundle?
ADatabase connections
BLarge images or files
CNetwork sockets
DSmall UI data like text or scroll position
True or False: onSaveInstanceState() is called when the user presses the back button.
AFalse
BDepends on Android version
COnly on some devices
DTrue
What happens if you don't save instance state during rotation?
AApp crashes immediately
BAndroid saves everything automatically
CUser input and UI state will be lost
DNothing changes
Explain how to save and restore UI state in an Android activity during screen rotation.
Think about which methods handle saving and restoring, and what kind of data to save.
You got /5 concepts.
    Why is it important to save instance state in mobile apps? Give an example scenario.
    Imagine what happens if the user types something and rotates the device.
    You got /4 concepts.