Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazonアプリストア
Ring
AWS
ドキュメント
Support
Contact Us
My Cases
開発
設計と開発
公開
リファレンス
サポート
メインコンテンツへスキップ
AsyncStorage is an unencrypted, asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of LocalStorage. It is recommended that you use an abstraction on top of AsyncStorage instead of AsyncStorage directly for anything more than light usage since it operates globally.

Installation

Importing the legacy version of the AsyncStorage library:
Note: AsyncStorage was recently removed from the mainline React Native libraries. We are working on creating a path to use AsyncStorage more idiomatically. Until this is completed, include AsyncStorage in place of the import as follows:
Be aware that this imports AsyncStorage as type any, thus any related code will have relaxed type checking. Persisting data:
Fetching data:

API reference

getItem()

Fetches an item for a key and invokes a callback upon completion. Returns a Promise object. Parameters:

setItem()

Sets the value for a key and invokes a callback upon completion. Returns a Promise object. Parameters:

removeItem()

Removes an item for a key and invokes a callback upon completion. Returns a Promise object. Parameters:

clear()

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. Parameters:

multiGet()

This allows you to batch the fetching of items given an array of key inputs. Your callback will be invoked with an array of corresponding key-value pairs found:
The method returns a Promise object. Parameters: Example:

multiSet()

Use this as a batch operation for storing multiple key-value pairs. When the operation completes you’ll get a single callback with any errors:
The method returns a Promise object. Parameters:

multiRemove()

Call this to batch the deletion of all keys in the keys array. Returns a Promise object. Parameters: Example:
最終更新日 2026年10月26日