Skip to content

Commit 5483ee3

Browse files
committed
fix encryption on android not working
1 parent 7edf7ad commit 5483ee3

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

android/src/main/java/com/ammarahmed/mmkv/IDStore.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33
import android.os.Bundle;
44

55
import androidx.annotation.Nullable;
6-
7-
import com.facebook.react.bridge.Arguments;
8-
import com.facebook.react.bridge.WritableArray;
9-
import com.facebook.react.bridge.WritableMap;
106
import com.tencent.mmkv.MMKV;
11-
127
import java.util.HashMap;
13-
import java.util.HashSet;
14-
import java.util.Map;
15-
import java.util.Set;
168

179
public class IDStore {
1810

@@ -105,10 +97,12 @@ public HashMap<String, Object> getAll() {
10597
public boolean exists(String ID) {
10698
boolean hasKey = store.containsKey("mmkvIdStore");
10799
if (hasKey) {
108-
Set<String> IdStore = new HashSet<>();
109-
IdStore = store.decodeStringSet("mmkvIdStore", IdStore);
100+
HashMap<String, Object> IdStore = new HashMap<>();
101+
Bundle mmkvIdStore = store.decodeParcelable("mmkvIdStore", Bundle.class);
102+
IdStore = (HashMap<String, Object>) mmkvIdStore.getSerializable("mmkvIdStore");
103+
110104

111-
return IdStore.contains(ID);
105+
return IdStore.containsKey(ID);
112106

113107
} else {
114108

android/src/main/java/com/ammarahmed/mmkv/RNMMKVModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ public void setupWithEncryption(String ID, int mode, String cryptKey, @Nullable
106106
mmkvMap.put(ID, kv);
107107
callback.invoke(null, true);
108108
} else {
109-
110109
if (kv.containsKey(ID)) {
111110
mmkvMap.put(ID, kv);
112111
callback.invoke(null, true);
113112
} else {
114-
115113
encryptionHandler(ID, mode, callback);
116114
}
117115
}

0 commit comments

Comments
 (0)