SUPStorage.js

Functions to store results from online requests in a specified cache.

Storage functions enable you to:
  • Name the cached result sets
  • Enumerate the cached result sets
  • Read, delete, and modify cached contents individually for each cached result set
Usage Notes: PhoneGap must be initialized before a storage function is called. The initialization happens automatically when you generate code using the Hybrid App Designer; if you do not use Designer, you must detect PhoneGap initialization in your own code. See Implementing PhoneGap.

Cached result sets must be stored as strings (before deserialization to an xmlWorkflowMessage structure).

Calls to these methods do not trigger events.

Example: Constructors

// These constructors create two local storage instances with their own domain
var store1 = new hwc.SUPStorage("mydomain");
var store2 = new hwc.SUPStorage("myotherdomain");

// This constructor creates a shared storage instance whose key is the one set in the 
// packaging tool for generated JavaScript API, or in the Hybrid App Designer.
var storeS = new hwc.SharedStorage();

Example: length

// Displays the current number of elements in the storage
var store = new hwc.SUPStorage();
alert(store.length());

Example: key(index)

// Displays the value at the provided index in the storage
var store = new hwc.SUPStorage();
alert(store.key(2));

Example: getItem(key)


// Displays the value for the provided key
var store = new hwc.SUPStorage();
alert(store.getItem("mykey"));

Example: setItem(key, value)

// Sets a key/value pair
var store = new hwc.SUPStorage();
store.setItem("mykey", "myvalue");

Example: emoveItem(key)

// Removes a key/value pair
var store = new hwc.SUPStorage();
store.removeItem("mykey");

Example: clear

// Clears the storage
var store = new hwc.SUPStorage();
store.clear();
Related reference
AttachmentViewer and Image Limitations