In a previous lesson, you learned about the remember composable function. The remember function saves the state across recomposition. However, the state would be lost when a configuration change occurs.
To save state across a configuration change like screen rotation, use the rememberSaveable composable function. rememberSaveable saves state values in a Bundle object.
This is how you’d create a MutableState object in a composable using the rememberSaveable function:
var friendsName by rememberSaveable { mutableStateOf("") }
In the next lesson, you’ll use rememberSaveable in a hands-on experience to save state across configuration changes in the Wellness Club App.
See forum comments
This content was released on Sep 10 2024. The official support period is 6-months
from this date.
In this lesson, you’ll learn the techniques to save state across a configuration change in an Android app.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.