public class PreferencesUtils
extends java.lang.Object
PREFERENCE_NAME
putString(android.content.Context, String, String)
putInt(android.content.Context, String, int)
putLong(android.content.Context, String, long)
putFloat(android.content.Context, String, float)
putBoolean(android.content.Context, String, boolean)
getString(android.content.Context, String)
, getString(android.content.Context, String, String)
getInt(android.content.Context, String)
, getInt(android.content.Context, String, int)
getLong(android.content.Context, String)
, getLong(android.content.Context, String, long)
getFloat(android.content.Context, String)
, getFloat(android.content.Context, String, float)
getBoolean(android.content.Context, String)
, getBoolean(android.content.Context, String, boolean)
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
PREFERENCE_NAME |
构造器和说明 |
---|
PreferencesUtils() |
限定符和类型 | 方法和说明 |
---|---|
static void |
clearSharePreference(android.content.Context context) |
static void |
clearSharePreference(android.content.Context context,
java.lang.String preferenceName) |
static boolean |
getBoolean(android.content.Context context,
java.lang.String key)
get boolean preferences, default is false
|
static boolean |
getBoolean(android.content.Context context,
java.lang.String key,
boolean defaultValue)
get boolean preferences
|
static boolean |
getBoolean(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
boolean defaultValue) |
static float |
getFloat(android.content.Context context,
java.lang.String key)
get float preferences
|
static float |
getFloat(android.content.Context context,
java.lang.String key,
float defaultValue)
get float preferences
|
static float |
getFloat(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
float defaultValue) |
static int |
getInt(android.content.Context context,
java.lang.String key)
get int preferences
|
static int |
getInt(android.content.Context context,
java.lang.String key,
int defaultValue)
get int preferences
|
static int |
getInt(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
int defaultValue) |
static long |
getLong(android.content.Context context,
java.lang.String key)
get long preferences
|
static long |
getLong(android.content.Context context,
java.lang.String key,
long defaultValue)
get long preferences
|
static long |
getLong(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
long defaultValue) |
static java.lang.String |
getString(android.content.Context context,
java.lang.String key)
get string preferences
|
static java.lang.String |
getString(android.content.Context context,
java.lang.String key,
java.lang.String defaultValue)
get string preferences
|
static java.lang.String |
getString(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
java.lang.String defaultValue) |
static boolean |
putBoolean(android.content.Context context,
java.lang.String key,
boolean value)
put boolean preferences
|
static boolean |
putBoolean(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
boolean value) |
static boolean |
putFloat(android.content.Context context,
java.lang.String key,
float value)
put float preferences
|
static boolean |
putFloat(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
float value) |
static boolean |
putInt(android.content.Context context,
java.lang.String key,
int value)
put int preferences
|
static boolean |
putInt(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
int value) |
static boolean |
putLong(android.content.Context context,
java.lang.String key,
long value)
put long preferences
|
static boolean |
putLong(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
long value) |
static boolean |
putString(android.content.Context context,
java.lang.String key,
java.lang.String value)
put string preferences
|
static boolean |
putString(android.content.Context context,
java.lang.String preferenceName,
java.lang.String key,
java.lang.String value) |
public static boolean putString(android.content.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 boolean putString(android.content.Context context, java.lang.String preferenceName, java.lang.String key, java.lang.String value)
public static java.lang.String getString(android.content.Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetString(android.content.Context, String, String)
public static java.lang.String getString(android.content.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 java.lang.String getString(android.content.Context context, java.lang.String preferenceName, java.lang.String key, java.lang.String defaultValue)
public static boolean putInt(android.content.Context context, java.lang.String key, int value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static boolean putInt(android.content.Context context, java.lang.String preferenceName, java.lang.String key, int value)
public static int getInt(android.content.Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetInt(android.content.Context, String, int)
public static int getInt(android.content.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 int getInt(android.content.Context context, java.lang.String preferenceName, java.lang.String key, int defaultValue)
public static boolean putLong(android.content.Context context, java.lang.String key, long value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static boolean putLong(android.content.Context context, java.lang.String preferenceName, java.lang.String key, long value)
public static long getLong(android.content.Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetLong(android.content.Context, String, long)
public static long getLong(android.content.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 long getLong(android.content.Context context, java.lang.String preferenceName, java.lang.String key, long defaultValue)
public static boolean putFloat(android.content.Context context, java.lang.String key, float value)
context
- key
- The name of the preference to modifyvalue
- The new value for the preferencepublic static boolean putFloat(android.content.Context context, java.lang.String preferenceName, java.lang.String key, float value)
public static float getFloat(android.content.Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetFloat(android.content.Context, String, float)
public static float getFloat(android.content.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 float getFloat(android.content.Context context, java.lang.String preferenceName, java.lang.String key, float defaultValue)
public static boolean putBoolean(android.content.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 putBoolean(android.content.Context context, java.lang.String preferenceName, java.lang.String key, boolean value)
public static boolean getBoolean(android.content.Context context, java.lang.String key)
context
- key
- The name of the preference to retrievegetBoolean(android.content.Context, String, boolean)
public static boolean getBoolean(android.content.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 existpublic static boolean getBoolean(android.content.Context context, java.lang.String preferenceName, java.lang.String key, boolean defaultValue)
public static void clearSharePreference(android.content.Context context)
public static void clearSharePreference(android.content.Context context, java.lang.String preferenceName)