Guest User

Untitled

a guest
Jan 17th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. SharedPreferences sp = context.getSharedPreferences("loginSaved", Context.MODE_PRIVATE);
  2. SharedPreferences.Editor editor = sp.edit();
  3. editor.putString("username", "some user value");
  4. editor.putString("password", "some password value");
  5. editor.commit();
  6.  
  7. SharedPreferences sp = context.getSharedPreferences("loginSaved", Context.MODE_PRIVATE);
  8. String username = sp.getString("username", null);
  9. String password = sp.getString("password", null);
  10. if(username != null && password != null){
  11. // login automatically with username and password
  12. }
  13. else{
  14. // login for the first time
  15. }
Add Comment
Please, Sign In to add comment