SharedPrefrences


public class SharedPrefrences {

    private Context mContext;
    private static final String MYPREFS = "RevolverLifeSharedPreference";
    private SharedPreferences settings;
    private SharedPreferences.Editor editor;
    public final String USERDETAIL = "User";
    public final String LAST_APP_OPEN_DATE = "LastAppOpenDate";
    public final String APP_OPEN_COUNT = "AppOpenCount";

    public SharedPrefrences(Context Ctx) {
        mContext = Ctx;
        settings = mContext.getSharedPreferences(MYPREFS, 0);
        editor = settings.edit();
    }

    // Set the Access Token and Other Important Keys in SharedPrefernces
    public void setPreferences(String Key, String Value) {
        editor.putString(Key, Value);
        editor.commit();
    }

    // get the Access Token and Other Important Keys in SharedPrefernces
    public String getPreferences(String Key, String Value) {
        return settings.getString(Key, Value);
    }


    // Set the Access Token and Other Important Keys in SharedPrefernces
    public void setPreferences(String Key, int Value) {
        editor.putInt(Key, Value);
        editor.commit();
    }

    // get the Access Token and Other Important Keys in SharedPrefernces
    public int getPreferences(String Key, int Value) {
        return settings.getInt(Key, Value);
    }

    // Get Login User
    public LoginUser getLoginUser() {
        Gson gson = new Gson();
        LoginUser user = gson.fromJson(getPreferences(USERDETAIL, ""), LoginUser.class);
        return user;
    }
}