Storage.getItem()

Overview

Gets a value from the application's internal persistent store. The values stored are shared between all profiles and sessions on the device and will persist until the application is uninstalled or the application's data is cleared.

Added in version 1.2.109

Use Cases

Your script needs to maintain state between sessions.

Format

var storedItem = Storage.getItem(keyName);

Parameter Description Type Required Notes
keyName A string key that was used to store the value previously. String Required
storedItem The returned stored item. The item can be of any type that can be stored using JSON. String, Number, Boolean, Array, Object Return Value If the value has never be set, this function will return null.

Example

Copy
/* Play a sound file the very first time this code is processed.
 */
 
if(!Storage.getItem('doneThisOnce')) {
  Device.beepPlayFile('tada.wav');
  Storage.setItem('doneThisOnce', true);
}