JavaScript Reference

Local Navigation

Storage API

Object

Description

Availability

Database

Represents a basic relational database stored on the BlackBerry device.

6.0 or later

Storage

Provides methods and properties used by both session and local storage objects.

6.0 or later

StorageEvent

Represents an event that is fired when data in the storage area is updated.

6.0 or later

Object: Database

Availability

BlackBerry Device Software version 6.0 or later

The Database object represents a lightweight relational database on the BlackBerry device. You use SQLite queries to retrieve, add, modify, and delete data.

You access the database using window.openDatabase() method. If the database with the given name doesn't already exist when openDatabase() is called, the browser creates it.

To create a database on a device, the device must have an microSD card mounted and available. When you create a database, the browser creates a database for an application in a domain-specific subfolder on the device SDCard.

The BlackBerry Browser follows the same-origin policy for allowing access to client-side databases. Web applications are only permitted to access those resources with the same scheme, domain, and port number, as the application. An application can access a database only by using path names that are relative to the origin domain. Applications cannot access databases using absolute path names.

Back To Top

Database properties

Property name

Type

Description

Status

Support level

Availability

version

DOMString

Returns the current version of the database.

read only

Web Database

6.0 or later

Back To Top

Database methods

Method name

Description

Support level

Availability

changeVersion()

Changes the version number of the database at the same time as doing a schema update.

Web Database

6.0 or later

readTransaction()

Creates SQLTransaction object for a read-only transaction.

Web Database

6.0 or later

transaction()

Creates SQLTransaction object for a read/write transaction.

Web Database

6.0 or later

Back To Top

Object: Storage

Availability

BlackBerry Device Software version 6.0 or later

The Storage object is used to storage a collection of key/value pairs.

Storage objects are instantiated as one of the following types:

  • sessionStorage: Storage objects of this type let you to store data only for the duration of the current browser session. Once the session is closed on the device, the storage object and the data it contains is deleted.

  • localStorage: Storage objects of this type let you store data that persists across browser sessions. When you create a new localStorage object, it is stored based on the origin domain of the original HTML document.

    The BlackBerry Browser follows the same-origin policy for allowing access to localStorage objects. Web applications are only permitted to access those objects with the same scheme, domain, and port number, as the application. An application can access a localStorage object only by using path names that are relative to the origin domain.

You can assign a key/value pair to a Storage object by using the setItem() method. For example:

localStorage.setItem("name1", value1);

Alternatively, you can index the objects directly using square brackets. For example:

localStorage["name1"] = value1;
Back To Top

Storage properties

Property name

Type

Description

Status

Support level

Availability

length

unsigned long

Returns the number of key/value pairs contained by the Storage object.

read only

Web Storage

6.0 or later

Back To Top

Storage methods

Method name

Description

Support level

Availability

clear()

Empties the Storage object of any contained key/value pairs.

Web Storage

6.0 or later

getItem()

Returns a structured clone of the current value of the given key, if it exists.

Web Storage

6.0 or later

key()

Returns the key at the given position in the list of keys contained by the Storage object.

Web Storage

6.0 or later

removeItem()

Removes the key/value pair with the given key from the Storage object, if it exists.

Web Storage

6.0 or later

setItem()

Adds a new key/value pair to the list of key/value pairs contained by the Storage object.

Web Storage

6.0 or later

Back To Top

Object: StorageEvent

Availability

BlackBerry Device Software version 6.0 or later

Extends

Event

The StorageEvent object extends the Event object and represents an event fired when a local or session storage area changes.

Back To Top

StorageEvent properties

Property name

Type

Description

Status

Support level

Availability

key

DOMString

Returns the key being changed.

read only

Web Storage

6.0 or later

newValue

any

Returns the new value of the key being changed.

read only

Web Storage

6.0 or later

oldValue

any

Returns the old value of the key being changed.

read only

Web Storage

6.0 or later

storageArea

Storage

Returns the affected Storage object.

read only

Web Storage

6.0 or later

url

DOMString

Returns the address of the document whose key changed.

read only

Web Storage

6.0 or later

Back To Top

StorageEvent methods

Method name

Description

Support level

Availability

initStorageEvent()

Initializes a StorageEvent.

Web Storage

6.0 or later

Back To Top
Next topic: Thread API
Previous topic: Range methods

Was this information helpful? Send us your comments.