Scandit.LocalStorage

Simple key/value storage shared between all activities on the device.

Methods

(static) delete(key: string): Promise

Deletes value by key

Parameters:
Name Type Description
key string
Returns:
Examples
  • JavaScript
  • ES6
Scandit.LocalStorage.delete('key');
Scandit.LocalStorage.delete('key');

(static) get(key: string): Promise<(string|null)>

Will return the passed key's value

Parameters:
Name Type Description
key string
Returns:
Promise<(string|null)>

Promise which is resolved to the string value of the key, or null if the key does not exist in storage

Examples
  • JavaScript
  • ES6
Scandit.LocalStorage.get('key')
.then(function(value) {
  if (value) {
    console.log(key + ': ' + value);
  }
}).catch(console.error);
Scandit.LocalStorage.get('key')
.then(value => {
  if (value) {
    console.log(`${key}: ${value}`);
  }
}).catch(console.error);

(static) put(key: string, value: string): Promise

Will set the passed key's value, adding it to the storage, or updating it if the key's value already exists

Parameters:
Name Type Description
key string
value string
Returns:
Examples
  • JavaScript
  • ES6
Scandit.LocalStorage.put('key');
Scandit.LocalStorage.put('key');