SpUtils.java
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.polysoft.nafmii.utils;
import android.content.Context;
import android.content.SharedPreferences;
public class SpUtils {
private static final String SP_NAME = "NAFMII";
// 首次运行
public static final String KEY_FIRST_RUN = "FIRST_RUN";
// H5版本
public static final String KEY_H5_VERSION = "H5_VERSION";
public static void putBoolean(String key, boolean val) {
SharedPreferences.Editor edit = getSpMgr().edit();
edit.putBoolean(key, val).commit();
}
public static boolean getBoolean(String key, boolean def) {
return getSpMgr().getBoolean(key, def);
}
public static void putString(String key, String val) {
SharedPreferences.Editor edit = getSpMgr().edit();
edit.putString(key, val).commit();
}
public static String getString(String key, String def) {
return getSpMgr().getString(key, def);
}
private static SharedPreferences getSpMgr() {
return CtxUtils.getApplication().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
}
}