|
|
|
@ -0,0 +1,47 @@ |
|
|
|
package com.vernu.sms.helpers; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.content.SharedPreferences; |
|
|
|
|
|
|
|
public class SharedPreferenceHelper { |
|
|
|
private final static String PREF_FILE = "PREF"; |
|
|
|
|
|
|
|
|
|
|
|
static void setSharedPreferenceString(Context context, String key, String value){ |
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0); |
|
|
|
SharedPreferences.Editor editor = settings.edit(); |
|
|
|
editor.putString(key, value); |
|
|
|
editor.apply(); |
|
|
|
} |
|
|
|
|
|
|
|
static void setSharedPreferenceInt(Context context, String key, int value){ |
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0); |
|
|
|
SharedPreferences.Editor editor = settings.edit(); |
|
|
|
editor.putInt(key, value); |
|
|
|
editor.apply(); |
|
|
|
} |
|
|
|
|
|
|
|
static void setSharedPreferenceBoolean(Context context, String key, boolean value){ |
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0); |
|
|
|
SharedPreferences.Editor editor = settings.edit(); |
|
|
|
editor.putBoolean(key, value); |
|
|
|
editor.apply(); |
|
|
|
} |
|
|
|
|
|
|
|
static String getSharedPreferenceString(Context context, String key, String defValue){ |
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0); |
|
|
|
return settings.getString(key, defValue); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int getSharedPreferenceInt(Context context, String key, int defValue){ |
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0); |
|
|
|
return settings.getInt(key, defValue); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static boolean getSharedPreferenceBoolean(Context context, String key, boolean defValue){ |
|
|
|
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0); |
|
|
|
return settings.getBoolean(key, defValue); |
|
|
|
} |
|
|
|
} |