Skip to content

Commit b7f86f2

Browse files
committed
2 parents 39d5312 + 471020a commit b7f86f2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ It allows you to save any type or list in the sharedpreferences and retrieve it
2121
Add the dependency in your app build.gradle
2222
```gradle
2323
dependencies {
24-
implementation 'com.github.yehiahd:FastSave-Android:1.0.3'
24+
implementation 'com.github.yehiahd:FastSave-Android:1.0.4'
2525
}
2626
```
2727

@@ -43,7 +43,7 @@ It allows you to save any type or list in the sharedpreferences and retrieve it
4343
<dependency>
4444
<groupId>com.github.yehiahd</groupId>
4545
<artifactId>FastSave-Android</artifactId>
46-
<version>1.0.3</version>
46+
<version>1.0.4</version>
4747
</dependency>
4848
```
4949

fastsave/src/main/java/com/appizona/yehiahd/fastsave/FastSave.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void saveInt(String key, int value) {
4242
}
4343

4444
public int getInt(String key) {
45-
if (isValidKey(key)) {
45+
if (isKeyExists(key)) {
4646
return mSharedPreferences.getInt(key, 0);
4747
}
4848
return 0;
@@ -55,7 +55,7 @@ public void saveBoolean(String key, boolean value) {
5555
}
5656

5757
public boolean getBoolean(String key) {
58-
if (isValidKey(key)) {
58+
if (isKeyExists(key)) {
5959
return mSharedPreferences.getBoolean(key, false);
6060
} else {
6161
return false;
@@ -70,7 +70,7 @@ public void saveFloat(String key, float value) {
7070
}
7171

7272
public float getFloat(String key) {
73-
if (isValidKey(key)) {
73+
if (isKeyExists(key)) {
7474
return mSharedPreferences.getFloat(key, 0.0f);
7575
}
7676
return 0.0f;
@@ -84,7 +84,7 @@ public void saveLong(String key, long value) {
8484
}
8585

8686
public long getLong(String key) {
87-
if (isValidKey(key)) {
87+
if (isKeyExists(key)) {
8888
return mSharedPreferences.getLong(key, 0);
8989
}
9090
return 0;
@@ -98,7 +98,7 @@ public void saveString(String key, String value) {
9898
}
9999

100100
public String getString(String key) {
101-
if (isValidKey(key)) {
101+
if (isKeyExists(key)) {
102102
return mSharedPreferences.getString(key, null);
103103
}
104104
return null;
@@ -112,7 +112,7 @@ public <T> void saveObject(String key, T object) {
112112
}
113113

114114
public <T> T getObject(String key, Class<T> classType) {
115-
if (isValidKey(key)) {
115+
if (isKeyExists(key)) {
116116
String objectString = mSharedPreferences.getString(key, null);
117117
if (objectString != null) {
118118
return new Gson().fromJson(objectString, classType);
@@ -130,7 +130,7 @@ public <T> void saveObjectsList(String key, List<T> objectList) {
130130
}
131131

132132
public <T> List<T> getObjectsList(String key, Class<T> classType) {
133-
if (isValidKey(key)) {
133+
if (isKeyExists(key)) {
134134
String objectString = mSharedPreferences.getString(key, null);
135135
if (objectString != null) {
136136
return new Gson().fromJson(objectString, new com.google.common.reflect.TypeToken<List<T>>() {
@@ -151,7 +151,7 @@ public void clearSession() {
151151
}
152152

153153
public boolean deleteValue(String key) {
154-
if (isValidKey(key)) {
154+
if (isKeyExists(key)) {
155155
SharedPreferences.Editor editor = mSharedPreferences.edit();
156156
editor.remove(key);
157157
editor.apply();
@@ -167,7 +167,7 @@ private static void validateInitialization() {
167167
throw new FastException("FastSave Library must be initialized inside your application class by calling FastSave.init(getApplicationContext)");
168168
}
169169

170-
private boolean isValidKey(String key) {
170+
public boolean isKeyExists(String key) {
171171
Map<String, ?> map = mSharedPreferences.getAll();
172172
if (map.containsKey(key)) {
173173
return true;

0 commit comments

Comments
 (0)