-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppData.java
80 lines (63 loc) · 2.82 KB
/
AppData.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package sg.pocketseed.database;
import android.content.Context;
public class AppData {
//GLOBAL_PREF is used to save FCM token
public static final String GLOBAL_PREF = "GLOBAL_PREF";
public static final String DEVICE_ID = "device_id";
public static final String IS_LOGIN = "login_status";
public static final String USER_TOKEN = "user_token";
public static final String PROFILE_PIC = "PROFILE_PIC";
public static final String IS_PIC_UPDATED = "IS_PIC_UPDATED";
public static final String IS_SHOW_COACH_MARK = "IS_SHOW_COACH_MARK";
public static final String JSON_RES = "JSON_RES";
public static final String DOWNLOADED_TASK = "DOWNLOADED_TASK";
public static final String EMAIL_ID = "EMAIL_ID";
public static final String THEME_RESPONSE = "THEME_RESPONSE";
public static final String default_pref = "skills_on_wheels";
public static final String THEME_RES = "THEME_RES";
public static void save(Context context, String key, String value) {
save(default_pref, context, key, value);
}
public static void save(String prefName, Context context, String key, String value) {
context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
.edit()
.putString(key, value)
.apply();
}
public static void save(String prefName, Context context, String key, boolean value) {
context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
.edit()
.putBoolean(key, value)
.apply();
}
public static void save(Context context, String key, boolean value) {
save(default_pref, context, key, value);
}
public static String getString(String prefName, Context context, String key) {
return context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
.getString(key, "");
}
public static String getString(Context context, String key) {
return getString(default_pref, context, key);
}
public static int getInt(String prefName, Context context, String key) {
return context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
.getInt(key, 0);
}
public static int getInt(Context context, String key) {
return getInt(default_pref, context, key);
}
public static boolean getBoolean(String prefName, Context context, String key) {
return context.getSharedPreferences(prefName, Context.MODE_PRIVATE)
.getBoolean(key, false);
}
public static boolean getBoolean(Context context, String key) {
return getBoolean(default_pref, context, key);
}
public static void clearAll(Context context) {
context.getSharedPreferences(default_pref, Context.MODE_PRIVATE)
.edit()
.clear()
.apply();
}
}