rn-async-storage
rn-async-storage copied to clipboard
Add removeItem method to the API
AsyncStorage.removeItem()
doesn't exist for Android. Can the API include this and the other methods? I've been using AsyncStorage.set('key', null)
as the work around.
getItem
setItem
removeItem
mergeItem
clear
getAllKeys
flushGetRequests
multiGet
multiSet
multiRemove
multiMerge
soon will coming birthday of this bug https://github.com/facebook/react-native/issues/14101 I will try to implement all methods until 22 May
Adding the following to java/org/gamega/RNAsyncStorageModule.java will add removeItem
/**
* Write string value by key
* @param key
*/
@ReactMethod
public void removeItem(String key, Promise promise){
try {
SharedPreferences sharedPref = getCurrentActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.remove(key);
editor.commit();
promise.resolve(null);
}catch (Exception e){
promise.reject(e);
e.printStackTrace();
}
}
It looks like this library's removeItem
is fixed in Github but npm is not updated.