@@ -30,7 +30,17 @@ public final class SPUtils {
30
30
* @return the single {@link SPUtils} instance
31
31
*/
32
32
public static SPUtils getInstance () {
33
- return getInstance ("" );
33
+ return getInstance ("" , Context .MODE_PRIVATE );
34
+ }
35
+
36
+ /**
37
+ * Return the single {@link SPUtils} instance
38
+ *
39
+ * @param mode Operating mode.
40
+ * @return the single {@link SPUtils} instance
41
+ */
42
+ public static SPUtils getInstance (final int mode ) {
43
+ return getInstance ("" , mode );
34
44
}
35
45
36
46
/**
@@ -40,10 +50,21 @@ public static SPUtils getInstance() {
40
50
* @return the single {@link SPUtils} instance
41
51
*/
42
52
public static SPUtils getInstance (String spName ) {
53
+ return getInstance (spName , Context .MODE_PRIVATE );
54
+ }
55
+
56
+ /**
57
+ * Return the single {@link SPUtils} instance
58
+ *
59
+ * @param spName The name of sp.
60
+ * @param mode Operating mode.
61
+ * @return the single {@link SPUtils} instance
62
+ */
63
+ public static SPUtils getInstance (String spName , final int mode ) {
43
64
if (isSpace (spName )) spName = "spUtils" ;
44
65
SPUtils spUtils = SP_UTILS_MAP .get (spName );
45
66
if (spUtils == null ) {
46
- spUtils = new SPUtils (spName );
67
+ spUtils = new SPUtils (spName , mode );
47
68
SP_UTILS_MAP .put (spName , spUtils );
48
69
}
49
70
return spUtils ;
@@ -53,6 +74,10 @@ private SPUtils(final String spName) {
53
74
sp = Utils .getApp ().getSharedPreferences (spName , Context .MODE_PRIVATE );
54
75
}
55
76
77
+ private SPUtils (final String spName , final int mode ) {
78
+ sp = Utils .getApp ().getSharedPreferences (spName , mode );
79
+ }
80
+
56
81
/**
57
82
* Put the string value in sp.
58
83
*
0 commit comments