Advertisement
Guest User

Untitled

a guest
May 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. public class session {
  2.     SharedPreferences peref;
  3.     SharedPreferences.Editor editeur;
  4.     Context context;
  5.  
  6.     public session(Context context) {
  7.         this.context = context;
  8.         peref = context.getSharedPreferences("appsave", Context.MODE_PRIVATE);
  9.         editeur = peref.edit();
  10.     }
  11.  
  12.     public void setLoggedin(boolean check_login, int id, String type) {
  13.         editeur.putBoolean("session", check_login);
  14.         editeur.putInt("id", id);
  15.         editeur.putString("type", type);
  16.         editeur.apply();
  17.     }
  18.  
  19.     public boolean logged() {
  20.         return peref.getBoolean("session", false);
  21.     }
  22.     public int loggedid() {
  23.         return peref.getInt("id",-1);
  24.  
  25.     }
  26. public String getType() {
  27.         return peref.getString("type","nothing");
  28.  
  29.     }
  30.  
  31.     public void logout(){
  32.         editeur.clear();
  33.         editeur.commit();
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement