public final class SPUtil
extends java.lang.Object
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
getBooleanOfSP(android.content.Context context,
java.lang.String type)
针对值为布尔值类型
获取指定名称的sp 的值 默认返回值为false
|
static SPUtil |
getInstance() |
int |
getIntOfSP(android.content.Context context,
java.lang.String type)
针对值为int类型
获取指定名称的sp 的值 默认返回值为空
|
int |
getIntOfSPAppType(android.content.Context context,
java.lang.String type)
针对值为int类型
获取指定名称的sp 的值 默认返回值为空
|
long |
getLongOfSP(android.content.Context context,
java.lang.String type) |
java.lang.String |
getStringOfSP(android.content.Context context,
java.lang.String type)
针对值为字符串类型
获取指定名称的sp 的值 默认返回值为空
|
boolean |
saveBooleanOfSP(android.content.Context context,
java.lang.String type,
boolean value)
存储指定名称的偏好设置 针对value为boolean类型
|
boolean |
saveIntOfSP(android.content.Context context,
java.lang.String type,
int value)
存储指定名称的偏好设置 针对value为int类型
|
boolean |
saveLongOfSP(android.content.Context context,
java.lang.String type,
long value) |
boolean |
saveMapOfSPKSVS(android.content.Context context,
java.util.HashMap<java.lang.String,java.lang.String> map)
存储map类型的偏好设置
|
boolean |
saveStringOfSP(android.content.Context context,
java.lang.String type,
java.lang.String value)
存储指定指定名称 指定值
|
public static SPUtil sp
public static SPUtil getInstance()
public boolean saveStringOfSP(android.content.Context context,
java.lang.String type,
java.lang.String value)
context - contexttype - 指定名称value - 指定值public boolean saveMapOfSPKSVS(android.content.Context context,
java.util.HashMap<java.lang.String,java.lang.String> map)
context - contextmap - key String value Stringpublic boolean saveBooleanOfSP(android.content.Context context,
java.lang.String type,
boolean value)
context - contexttype - typevalue - valuepublic boolean saveIntOfSP(android.content.Context context,
java.lang.String type,
int value)
context - contexttype - typevalue - valuepublic boolean saveLongOfSP(android.content.Context context,
java.lang.String type,
long value)
public java.lang.String getStringOfSP(android.content.Context context,
java.lang.String type)
context - contexttype - contextpublic boolean getBooleanOfSP(android.content.Context context,
java.lang.String type)
context - Contexttype - 要查询的keypublic int getIntOfSP(android.content.Context context,
java.lang.String type)
context - contexttype - typepublic long getLongOfSP(android.content.Context context,
java.lang.String type)
public int getIntOfSPAppType(android.content.Context context,
java.lang.String type)
context - contexttype - type