add getNativeBooleanSetting method

This commit is contained in:
Akinwale Ariwodola 2020-03-21 09:18:48 +01:00
parent 4d1f142f9c
commit 5aa0513324

View file

@ -456,6 +456,16 @@ public class UtilityModule extends ReactContextBaseJavaModule {
} }
} }
@ReactMethod
public void getNativeBooleanSetting(String key, boolean defaultValue, Promise promise) {
if (context != null) {
SharedPreferences sp = context.getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
promise.resolve(sp.getBoolean(key, defaultValue));
} else {
promise.resolve(null);
}
}
@ReactMethod @ReactMethod
public void setNativeStringSetting(String key, String value) { public void setNativeStringSetting(String key, String value) {
if (context != null) { if (context != null) {