'How to check if user is logged in and redirect them to the right screen using Jetpack Navigation

what is the best way to save user logged in state, check if they logged in or not and redirect them to the right screen. I'm not using firebase Auth in this current project please any help would be appreciated!



Solution 1:[1]

the page where we created the user

val prefences = activity?.getSharedPreferences("control", Context.MODE_PRIVATE)
val editor = prefences?.edit()
editor?.putString("usercontrol",value) // After creating the user you give value 1 
editor?.apply()

on the login page

val shared = getSharedPreferences("kontrol", MODE_PRIVATE)
        val control = shared.getLong("date", 0)

I suggest you look at the SharedPreferences structure

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ă–mer Seyfettin Yavuzyi?it