Hasen Hasen - 1 month ago 11x
iOS Question

React Native AsyncStorage storing values other than strings

Is there any way to store values other than strings with AsyncStorage? I want to store simple boolean values for example.

AsyncStorage.setItem('key', 'ok');

Is no problem, but:

AsyncStorage.setItem('key', false);

Does not work..


Based on the AsyncStorage React-native docs, I'm afraid you can only store strings..

static setItem(key: string, value: string, callback?: ?(error: ?Error)
> => void) 

Sets value for key and calls callback on completion, along with an Error if there is any. Returns a Promise object.

You might want to try and have a look at third party packages. Maybe this one.