Javatpoint Logo
Javatpoint Logo

AsyncStorage Methods

There are various methods of React Native AsyncStorage class are described below:

Methods

getItem()

The getItem() fetches an item from a key and invokes a callback upon completion. It returns a Promise object.

setItem()

The getItem() fetches an item from a key and invokes a callback upon completion. It returns a Promise object.

setItem()

The setItem() sets the value for a key and invokes a callback upon compilation. It returns a Promise object.

removeItem()

The removeItem() removes an item for a key and invokes a callback upon compilation. It returns a Promise object.

mergeItem()

The mergeItem() merges the existing key value with the input value and assuming both values are stringified JSON. It returns a Promise object.

NOTE: This method is not supported by all the native implementations.

clear()

The clear() method erases all AsynchStorage from all clients, libraries, etc. It is suggested that don't call this, instead of this may use removeItem or multiRemove to clear only your app?s keys. It returns the Promise object.

getAllKeys()

It gets all the keys which are known to your app, for all callers, libraries, etc. It returns a Promise object.

flushGetRequests()

It flushes any pending request using a single batch call to get the data.

multiGet()

This method allows you to batch the fetching of items given in an array of key inputs. The callback method will be invoked with an array of corresponding key-value pairs found:

The method returns a Promise object.

multiSet()

This method is used as a batch operation to store multiple key-value pairs. After the completion of operations, you will get a single callback with any errors:

The method returns a Promise object.

multiRemove()

This method calls the batch deletion of all keys in the key array. It returns a Promise object.

multiMerge()

It executes the batch operation to merge in existing and new values for a given set of keys. It assumes that the values are stringified JSON. It returns a Promise object.

Note: This method is not supported by all native implementations.


Next Topic#




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA