Reactnative (API) asyncstorage storage details and examples

Asyncstorage storage is similar to shared Preference Storage in Android or nsdefaultuser in IOS, but asyncstorage in reactnative can only store string types

Common methods:

Getitem (key: string, callback?:? (error:? Error, result:? String) = > void) static method, which queries the stored data through the key field, and passes the result value as a parameter into the second callback method. If an error occurs, the error object is passed into the callback method. This method finally returns a promise object

Setitem (key: string, value: string, callback?:? (error:? Error) = > void) static method, which sets the value content according to the key field, and calls back the callback method after completion. If an error occurs, the error object is passed into the callback method. This method returns a promise object.

Removeitem (key: string, callback?:? (error:? Error) = > void) static method. Delete the value according to the key. After success, call back the callback method. If an error occurs, the error object is passed into the callback method. This method returns a promise object.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>