Data Storage
Data Storage
The data storage module system.storage allows applications to store their own data. This data is persistently saved in the application's storage object. When the application is uninstalled, the data stored in system.storage will be cleared.
system.storage stores data in the form of key-value pairs, where the key must be a string and the value is a JSON value (or a JavaScript value that can be serialized to JSON).
Importing Modules
import storage from '@system.storage'
API
get
Gets the value corresponding to the key name key in storage. Returns undefined if the key-value pair does not exist.
set
This method accepts a key name key and a value value as parameters and adds this key-value pair to storage. If the key name already exists, its corresponding value is updated.
delete
Deletes the key-value pair corresponding to the key name key in storage. Returns true if the key-value pair exists and is successfully deleted.
clear
Clears all stored data in the application.
