HI i am working on a cordova app it required login. after login if i press the device back button the app getting logged out how to prevent that?
Basically when you click device back button, it will close the app. You didn't handle it.
Apparently, You have failed to save the login information and status(whether it is logged in already or not). That is the reason when you click back app is closing, which pretends to be logout.
To avoid going out of app, handle by using backbutton event.
Use this method after your device ready.
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown(){
alert("Back key is pressed");
// write your logics here;
}
Apparently to save the login details, use localStorage which will be available till you uninstall the app