Skip to content

Instantly share code, notes, and snippets.

@ishmaelmakitla
Created May 10, 2016 10:51
Show Gist options
  • Save ishmaelmakitla/1ce3adfddfa7ed7a3b9553cc2c7dcde7 to your computer and use it in GitHub Desktop.
Save ishmaelmakitla/1ce3adfddfa7ed7a3b9553cc2c7dcde7 to your computer and use it in GitHub Desktop.
private void getUserLogoutConfirmation(Context context, final SharedPreferences sharedPrefs){
new AlertDialog.Builder(context)
.setTitle("Loggin out of IshLema App")
.setMessage("Loging out will make the system ask you for username and password next time you use it.")
.setPositiveButton("Fine, Forget Me", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//remove the cached user
try{
Editor sharedPrefsEditor = sharedPrefs.edit();
sharedPrefsEditor.remove(USER_SHAREDPREFERENCE_KEY);
sharedPrefsEditor.remove(USER_SHAREDPREFERENCE_VALIDITY_KEY);
sharedPrefsEditor.commit();
finish();
}catch(Exception e){
Log.e(TAG, "Error While Trying to Remove UserPreference to Forget User", e);
}
}
}).setNegativeButton("No, Remember Me", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing.
finish();
}
}).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment