Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class session {
- SharedPreferences peref;
- SharedPreferences.Editor editeur;
- Context context;
- public session(Context context) {
- this.context = context;
- peref = context.getSharedPreferences("appsave", Context.MODE_PRIVATE);
- editeur = peref.edit();
- }
- public void setLoggedin(boolean check_login, int id, String type) {
- editeur.putBoolean("session", check_login);
- editeur.putInt("id", id);
- editeur.putString("type", type);
- editeur.apply();
- }
- public boolean logged() {
- return peref.getBoolean("session", false);
- }
- public int loggedid() {
- return peref.getInt("id",-1);
- }
- public String getType() {
- return peref.getString("type","nothing");
- }
- public void logout(){
- editeur.clear();
- editeur.commit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement