I am developing an app where I am keeping boolean flag in SharedPreferences to check if current session is active or not. Based on this flag user gets navigated to either Home screen or Login screen after Splash screen is being shown.
This is working fine but one of our client has reported that his app keeps his user logged in even after uninstallation and re-installation of his app.
Steps he followed
- Install app
- Login using valid credentials
- Uninstall app from settings
- Re-install app using apk given by me
- Open app
I think when we uninstall app, its data gets cleared (including shared preferences), and this is working fine one other devices like Pixel 2, OnePlus 3 which are having same Android OS 8.0.
This is how I handled navigation. Here SessionManager is singleton (object in Kotlin) which stores isSessionActive flag. isSessionActive flag gets its value from SharedPreferences when application starts
val intent: Intent = if (SessionManager.isSessionActive) {
Intent(this, MainActivity::class.java)
} else {
Intent(this, LoginActivity::class.java)
}
startActivity(intent)
Can you suggest possible root cause of this behaviour and solution for this?