public class Saving {
public static String WITHOUT_MMS = "without_mms";
public static String WITH_FORM = "without_mms";
private static SharedPreferences getSharedPreferences(Context context) {
return context.getSharedPreferences("MAINTENANCE_MANAGEMENT_SYSTEM", Context.MODE_PRIVATE);
}
public static void setString(Context context, String key, String value) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString(key, value);
editor.apply();
}
public static void setInt(Context context, String key, int value) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putInt(key, value);
editor.apply();
}
public static String getString(Context context, String key) {
return getSharedPreferences(context).getString(key, "");
}
public static int getInt(Context context, String key) {
return getSharedPreferences(context).getInt(key, 0);
}
public static void setBoolean(Context context, String key, boolean value) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean(key, value);
editor.apply();
}
public static boolean getBoolean(Context context, String key) {
return getSharedPreferences(context).getBoolean(key, false);
}
//Clear SharedPreferences Data
public static void clearSharedPreferences(Context context) {
getSharedPreferences(context).edit().clear().apply();
}
}
0 Comments
Post a Comment