I have tried to logout from my app when the user clicks on Logout.It is working fine in case the user after login without closing the app if he doed logout .Then it is worki
You can use the SharedPreferences class in android. It can use to save the value and load it again. This is the docs and tutorial.
SharedPreferences