The value in remember { mutableStateOf()} can be hold after I finished the app?

The value in remember { mutableStateOf()} can be hold after I finished the app?

Problem Description:

I am developing the navigation flow of login by Jetpack compose.
Then I don’t understand the functions.

fun CheckSignedIn(vm: AuthViewModel,navController: NavController){
    val alreadyLoggedIn = remember { mutableStateOf(false)}
    val signedIn = vm.signedIn.value
    if(signedIn && !alreadyLoggedIn.value){
        alreadyLoggedIn.value = true
class AuthViewModel @Inject constructor(
    val auth: FirebaseAuth
): ViewModel() {

    val signedIn = mutableStateOf(false)
    init {
        signedIn.value = currentUser != null
fun SignupScreen(navController: NavController,vm:AuthViewModel){

    CheckSignedIn(vm = vm, navController = navController)


(I don’t write things which are no relation)

When SignupScreen’s compose is called, CheckSignedIn’s also is called.
I don’t know in CheckSignedIn how the value of remember { mutableStateOf(false)} is registered and working. My question is, If I finish the app, remember’s value is still registered or not?

Every the SignupScreen is called, will the all content of CheckSignedIn’s function start from the beginning?

Please tell me how to proceed in the all flow.
Thank you.

Solution – 1

remember helps us to save any state when the app is running or in the background so when you finish the app and start it again everything is going to start from zero, so alreadyLoggedIn state is going to go back to false when you restart the app.

To save states even after closing the app you need to take a look at data store:



Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.