@@ -42,7 +42,7 @@ public void saveInt(String key, int value) {
42
42
}
43
43
44
44
public int getInt (String key ) {
45
- if (isValidKey (key )) {
45
+ if (isKeyExists (key )) {
46
46
return mSharedPreferences .getInt (key , 0 );
47
47
}
48
48
return 0 ;
@@ -55,7 +55,7 @@ public void saveBoolean(String key, boolean value) {
55
55
}
56
56
57
57
public boolean getBoolean (String key ) {
58
- if (isValidKey (key )) {
58
+ if (isKeyExists (key )) {
59
59
return mSharedPreferences .getBoolean (key , false );
60
60
} else {
61
61
return false ;
@@ -70,7 +70,7 @@ public void saveFloat(String key, float value) {
70
70
}
71
71
72
72
public float getFloat (String key ) {
73
- if (isValidKey (key )) {
73
+ if (isKeyExists (key )) {
74
74
return mSharedPreferences .getFloat (key , 0.0f );
75
75
}
76
76
return 0.0f ;
@@ -84,7 +84,7 @@ public void saveLong(String key, long value) {
84
84
}
85
85
86
86
public long getLong (String key ) {
87
- if (isValidKey (key )) {
87
+ if (isKeyExists (key )) {
88
88
return mSharedPreferences .getLong (key , 0 );
89
89
}
90
90
return 0 ;
@@ -98,7 +98,7 @@ public void saveString(String key, String value) {
98
98
}
99
99
100
100
public String getString (String key ) {
101
- if (isValidKey (key )) {
101
+ if (isKeyExists (key )) {
102
102
return mSharedPreferences .getString (key , null );
103
103
}
104
104
return null ;
@@ -112,7 +112,7 @@ public <T> void saveObject(String key, T object) {
112
112
}
113
113
114
114
public <T > T getObject (String key , Class <T > classType ) {
115
- if (isValidKey (key )) {
115
+ if (isKeyExists (key )) {
116
116
String objectString = mSharedPreferences .getString (key , null );
117
117
if (objectString != null ) {
118
118
return new Gson ().fromJson (objectString , classType );
@@ -130,7 +130,7 @@ public <T> void saveObjectsList(String key, List<T> objectList) {
130
130
}
131
131
132
132
public <T > List <T > getObjectsList (String key , Class <T > classType ) {
133
- if (isValidKey (key )) {
133
+ if (isKeyExists (key )) {
134
134
String objectString = mSharedPreferences .getString (key , null );
135
135
if (objectString != null ) {
136
136
return new Gson ().fromJson (objectString , new com .google .common .reflect .TypeToken <List <T >>() {
@@ -151,7 +151,7 @@ public void clearSession() {
151
151
}
152
152
153
153
public boolean deleteValue (String key ) {
154
- if (isValidKey (key )) {
154
+ if (isKeyExists (key )) {
155
155
SharedPreferences .Editor editor = mSharedPreferences .edit ();
156
156
editor .remove (key );
157
157
editor .apply ();
@@ -167,7 +167,7 @@ private static void validateInitialization() {
167
167
throw new FastException ("FastSave Library must be initialized inside your application class by calling FastSave.init(getApplicationContext)" );
168
168
}
169
169
170
- private boolean isValidKey (String key ) {
170
+ public boolean isKeyExists (String key ) {
171
171
Map <String , ?> map = mSharedPreferences .getAll ();
172
172
if (map .containsKey (key )) {
173
173
return true ;
0 commit comments