openDatabase


Purpose

This method is used to create a database object either using the existing database or creating a new one, i.e. this method will open a database if it already exists; if the database does not exist the method will create it first.

The newly constructed database object represents the database with the given name. The method signature and behavior is the same as for the openSharedDatabase. This method overrides the openDatabase method from the window object.

Note

If the newly created database is intended to be the given user's private database, it is required that addAccount and openAccount methods are called first. If the sharingSwitch parameter is set to SHARED_AMONG_USERS, calling these two methods is not necessary.

Signature

openDatabase(name, version, displayName, estimatedSize, creationCallback, sharingSwitch)

Returns

This method returns a Database object.

Parameter

Name Description Type Use
name The name (case-sensitive) of the database to open or create. String required
version The database version. It can be an empty string. The database version number is required in order to open the database and it needs to match the database version that the client uses. A database can only have one version at a time. String required
displayName A textual description of the database. String required
estimatedSize An estimated size, in bytes, of the data that will be stored in the database. Unsigned Long required
creationCallback A callback method to be invoked if the database has not yet been created. It can, for example, contain table creation SQL statements. The callback, if provided, is invoked with the database having the empty string as its version regardless of the database version given by the version parameter. DatabaseCallback optional
sharingSwitch

Allows to decide if the database should be shared among users, among applications or both. It accepts the following two values:

  • window.launchbox.SQLStorage.SHARED_AMONG_APPS

  • window.launchbox.SQLStorage.SHARED_AMONG_USERS

If needed, settings may be combined using the "|" bitwise operator.

Integer optional

Related topics

openSharedDatabase
Overview
Web SQL Database
Legal notice | Copyright © 2016 and Confidential to Pegasystems Inc. All rights reserved
PDN | Hybrid Container | Feedback
Advanced...