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

1k Views Asked by At

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!

1

There are 1 best solutions below

5
On

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