React-Native AsyncStorage: What exactly does 'clear()' function clear?

Viewed 863

The official docs about .clear() are not very clear to me. They say the following:

Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this; use removeItem or multiRemove to clear only your app's keys. Returns a Promise object.

Can anybody explain, what 'all clients' exactly means in this context? For me it sounds like other RN-Apps stores could be affected too, I just can't imagine that this would even be possible.

2 Answers

It means everything that was stored by apps in asyncstorage will be cleared and yes it includes not only yours but other apps too it is clear from the documentation's this line

Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this use removeItem or multiRemove to clear only your app's keys.

means that it will clean everything you have added using setItem.

other RN-Apps stores could be affected too?

R/ No, AsyncStorage concat a appId (or something like that) to your setItem key to prevent remove info from another app.

Related