public class PreferencesUtils
extends java.lang.Object
PREFERENCE_NAME
putString(Context, String, String)
putInt(Context, String, int)
putLong(Context, String, long)
putFloat(Context, String, float)
putBoolean(Context, String, boolean)
getString(Context, String)
, getString(Context, String, String)
getInt(Context, String)
, getInt(Context, String, int)
getLong(Context, String)
, getLong(Context, String, long)
getFloat(Context, String)
, getFloat(Context, String, float)
getBoolean(Context, String)
, getBoolean(Context, String, boolean)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PREFERENCE_NAME |
Constructor and Description |
---|
PreferencesUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
getBoolean(Context context,
java.lang.String key)
get boolean preferences, default is false
|
static boolean |
getBoolean(Context context,
java.lang.String key,
boolean defaultValue)
get boolean preferences
|
static float |
getFloat(Context context,
java.lang.String key)
get float preferences
|
static float |
getFloat(Context context,
java.lang.String key,
float defaultValue)
get float preferences
|
static int |
getInt(Context context,
java.lang.String key)
get int preferences
|
static int |
getInt(Context context,
java.lang.String key,
int defaultValue)
get int preferences
|
static long |
getLong(Context context,
java.lang.String key)
get long preferences
|
static long |
getLong(Context context,
java.lang.String key,
long defaultValue)
get long preferences
|
static java.lang.String |
getString(Context context,
java.lang.String key)
get string preferences
|
static java.lang.String |
getString(Context context,
java.lang.String key,
java.lang.String defaultValue)
get string preferences
|
static boolean |
putBoolean(Context context,
java.lang.String key,
boolean value)
put boolean preferences
|
static boolean |
putFloat(Context context,
java.lang.String key,
float value)
put float preferences
|
static boolean |
putInt(Context context,
java.lang.String key,
int value)
put int preferences
|
static boolean |
putLong(Context context,
java.lang.String key,
long value)
put long preferences
|
static boolean |
putString(Context context,
java.lang.String key,
java.lang.String value)
put string preferences
|
public static boolean putString(Context context, java.lang.String key, java.lang.String value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static java.lang.String getString(Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetString(Context, String, String)
public static java.lang.String getString(Context context, java.lang.String key, java.lang.String defaultValue)
context
- key
- The name of the preference to retrievedefaultValue
- Value to return if this preference does not existpublic static boolean putInt(Context context, java.lang.String key, int value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static int getInt(Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetInt(Context, String, int)
public static int getInt(Context context, java.lang.String key, int defaultValue)
context
- key
- The name of the preference to retrievedefaultValue
- Value to return if this preference does not existpublic static boolean putLong(Context context, java.lang.String key, long value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static long getLong(Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetLong(Context, String, long)
public static long getLong(Context context, java.lang.String key, long defaultValue)
context
- key
- The name of the preference to retrievedefaultValue
- Value to return if this preference does not existpublic static boolean putFloat(Context context, java.lang.String key, float value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static float getFloat(Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetFloat(Context, String, float)
public static float getFloat(Context context, java.lang.String key, float defaultValue)
context
- key
- The name of the preference to retrievedefaultValue
- Value to return if this preference does not existpublic static boolean putBoolean(Context context, java.lang.String key, boolean value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static boolean getBoolean(Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetBoolean(Context, String, boolean)
public static boolean getBoolean(Context context, java.lang.String key, boolean defaultValue)
context
- key
- The name of the preference to retrievedefaultValue
- Value to return if this preference does not exist