You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
You can store with a fixed, known key a list of your keys of interest, or a JSON representation of a complex object containing all your data (instead of loose individual items with various keys). In both cases no particular library support is needed.
Thanks for your suggestion. I'm already doing the same. but I rather have library support for such functionality to get all the key -values by calling the function once. I already have to call the get function to retrieve all the keys and then call the get function for every key I retrieved. I think it's not good practice If an app contains lots of key-values. it will make RN bridge busy I guess.
One workaround for this is to set the keys at the same in both AsyncStorage and EncryptedStorage, and then fetch the values by looping over the keys and calling EncryptedStorage.getItem() for each key. This way at least you won't have to store the keys in a separate file.
For instance:
//Setting the values:
EncryptedStorage.setItem('key', '<actual value>');
AsyncStorage.setItem('key', 'null'); //Dummy value
//Fetching the values:
const keys = await AsyncStorage.getAllKeys();
const keyValueArray= await Promise.all(
keys .map(async key => {
const value = await EncryptedStorage.getItem(key);
return [key, value];
}),
);
Not ideal, but works. Especially in those cases where you don't know what the keys are in advance.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is there any functionality that returns all stored key values at once? I need to get all key-values to show a list to users
The text was updated successfully, but these errors were encountered: