SPreferences

public class SPreferences{

    protected final String TOKEN = "token";
    protected final String LOGIN = "login";
    protected final String USERNAME = "userName";
    protected final String PHONE = "phone";

    private Context context;
    private SharedPreferences sp;

    public SPreferences(Context context){
        this.context = context;
        sp = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
    }


    //------token------
    public void setToken(String token){
        sp.edit().putString(TOKEN, token).commit();
    }
    public String getToken(){
        return sp.getString(TOKEN, "n/a");
    }
    //-----------------



    //------login------
    public void setLogIn(boolean login){
        sp.edit().putBoolean(LOGIN, login).commit();
    }
    public boolean isLoggedIn(){
        return sp.getBoolean(LOGIN, false);
    }
    //-----------------
    
    
    
    //------username------
    public void setUserName(String userName){
        sp.edit().putString(USERNAME, userName).commit();
    }
    public String getUserName(){
        return sp.getString(USERNAME, "n/a");
    }
    //-----------------
    
    
    
    //------phone------
    public void setPhone(String phone){
        sp.edit().putString(PHONE, token).commit();
    }
    public String getPhone(){
        return sp.getString(PHONE, "n/a");
    }
    //-----------------

}