net.rim.device.api.database
Class DatabaseFactory

java.lang.Object
  extended by net.rim.device.api.database.DatabaseFactory

public class DatabaseFactory
extends Object

Creates new or opens existing instances of a SQLite database. Databases can be created as temporary (in-memory) or persistent (in-store) objects.

Example of setting a custom path: "/SDCard/MyRoot/Database/"

Example of creating a URI:

String path = "/SDCard/MyRoot/Database/MyDB"; 
 URI myURI = URI.create(path);

A microSD media card is the preferred storage for databases if the device supports it.

A database file can be encrypted or plain text. If the database is encrypted then it is linked to the device that created it. In order to transfer an encrypted database to another device, the database file must be decrypted first. Even when a database file is encrypted, the maximum protection level is achieved when content protection is turned on. An application can open or create an encrypted database only when the device is unlocked. An encrypted database should be closed as soon as possible. An open database connection is susceptible to cold boot attack.

The database may close automatically when the file system is unmounted. One such example is when a database file is stored on an external media card and the user connects the device to a desktop PC and enables USB mass storage mode. In this case the file system is managed by the desktop operating system and the BlackBerry device has no access to it. All the opened databases on the external card will be closed and cannot be opened until USB mass storage mode is finished.

Code sample: Adding content to a SQLite table

 import net.rim.device.api.database.Database;
 import net.rim.device.api.database.DatabaseFactory;
 import net.rim.device.api.database.Statement;
 import net.rim.device.api.io.URI;
 import net.rim.device.api.system.Application;
 
 public class AddDatabaseTable extends Application 
 {
    public static void main(String[] args)
   {
       AddDatabaseTable app = new AddDatabaseTable();
       try
       {
          URI myURI = URI.create("/SDCard/test.db"); 
          Database d = DatabaseFactory.open(myURI);
          Statement st = d.createStatement("INSERT INTO People(Name,Age) " +
                                           "VALUES ('John',37)");
          st.prepare();
          st.execute();
          st.close();
       }
       catch ( Exception e ) 
       {         
          System.out.println( e.getMessage() );
       }
   }
 }
 

See Also:
PersistentObject, DatabaseSecurityOptions
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

Method Summary
Category: Signed static Database create(String id)
          Creates a new plain text database.
Category: Signed static Database create(String id, DatabaseOptions databaseOptions)
          Creates a new plain text database with specified database options.
Category: Signed static Database create(String id, DatabaseSecurityOptions securityOptions)
          Creates a new database with the specified security options.
Category: Signed static Database create(String id, DatabaseSecurityOptions securityOptions, DatabaseOptions databaseOptions)
          Creates a new database with the specified security options and database options.
Category: Signed static Database create(URI fileURI)
          Creates a new plain text database.
Category: Signed static Database create(URI fileURI, DatabaseOptions databaseOptions)
          Creates a new plain text database with specified database options.
Category: Signed static Database create(URI fileURI, DatabaseSecurityOptions securityOptions)
          Creates a new database with specified security options.
Category: Signed static Database create(URI fileURI, DatabaseSecurityOptions securityOptions, DatabaseOptions databaseOptions)
          Creates a new database with specified security options and database options.
Category: Signed static void decrypt(String id)
          Decrypts an encrypted database.
Category: Signed static void decrypt(URI fileURI)
          Decrypts an encrypted database.
Category: Signed static void delete(String id)
          Removes an existing database from the device.
Category: Signed static void delete(URI fileURI)
          Removes an existing database from the device.
Category: Signed static void encrypt(String id, DatabaseSecurityOptions securityOptions)
          Encrypts a plain text database.
Category: Signed static void encrypt(URI fileURI, DatabaseSecurityOptions securityOptions)
          Encrypts a plain text database.
Category: Signed static boolean exists(String id)
          Checks whether a database already exists by specified ID.
Category: Signed static boolean exists(URI uri)
          Checks whether a database already exists by specified URI.
Category: Signed static String getDefaultRoot()
          Gets the default root at which database files are created.
Category: Signed static Database open(String id)
          Opens an existing database.
Category: Signed static Database open(String id, boolean readOnly)
          Opens an existing database.
Category: Signed static Database open(String id, boolean readOnly, DatabaseOptions databaseOptions)
          Opens an existing database with specified database options.
Category: Signed static Database open(String id, DatabaseOptions databaseOptions)
          Opens an existing database with specified database options.
Category: Signed static Database open(URI fileURI)
          Opens an existing database.
Category: Signed static Database open(URI fileURI, boolean readOnly)
          Opens an existing database.
Category: Signed static Database open(URI fileURI, boolean readOnly, DatabaseOptions databaseOptions)
          Opens an existing database with specified database options.
Category: Signed static Database open(URI fileURI, DatabaseOptions databaseOptions)
          Opens an existing database with the specified database options.
Category: Signed static Database openOrCreate(String id)
          Opens or creates a plain text database.
Category: Signed static Database openOrCreate(String id, DatabaseOptions databaseOptions)
          Opens or creates a plain text database with specified database options.
Category: Signed static Database openOrCreate(String id, DatabaseSecurityOptions securityOptions)
          Opens or creates an encrypted database.
Category: Signed static Database openOrCreate(String id, DatabaseSecurityOptions securityOptions, DatabaseOptions databaseOptions)
          Opens or creates an encrypted database with specified database options.
Category: Signed static Database openOrCreate(URI fileURI)
          Opens or creates a plain text database.
Category: Signed static Database openOrCreate(URI fileURI, DatabaseOptions databaseOptions)
          Opens or creates a plain text database with specified database options.
Category: Signed static Database openOrCreate(URI fileURI, DatabaseSecurityOptions securityOptions)
          Opens or creates a database.
Category: Signed static Database openOrCreate(URI fileURI, DatabaseSecurityOptions securityOptions, DatabaseOptions databaseOptions)
          Opens or creates a database with the specified database options.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

getDefaultRoot

public static String getDefaultRoot()
Gets the default root at which database files are created.

Returns:
The default root at which database files are created.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

create

public static Database create(String id,
                              DatabaseSecurityOptions securityOptions)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new database with the specified security options.

If the securityOptions argument is null, the database will be plain text and accessible from any application.

Parameters:
id - Database filename using the default root.
securityOptions - Defines optional database security options, such as encryption.
Returns:
Database instance.
Throws:
DatabasePathException
DatabaseIOException
See Also:
DatabaseFactory.create(String)
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

create

public static Database create(String id,
                              DatabaseSecurityOptions securityOptions,
                              DatabaseOptions databaseOptions)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new database with the specified security options and database options.

If the securityOptions argument is null then the database will be plain text and accessible from any application.

Parameters:
id - Database filename using the default root.
securityOptions - Defines optional database security options, such as encryption.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabasePathException
DatabaseIOException
See Also:
DatabaseFactory.create(String)
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

create

public static Database create(String id)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new plain text database.

Parameters:
id - Database filename using the default root.
Returns:
Instance of a new database.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

create

public static Database create(String id,
                              DatabaseOptions databaseOptions)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new plain text database with specified database options.

Parameters:
id - Database filename using the default root.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Instance of a new database.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

create

public static Database create(URI fileURI)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new plain text database.

Parameters:
fileURI - URI of the database file.
Returns:
Database instance.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

create

public static Database create(URI fileURI,
                              DatabaseOptions databaseOptions)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new plain text database with specified database options.

Parameters:
fileURI - URI of the database file.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

create

public static Database create(URI fileURI,
                              DatabaseSecurityOptions securityOptions)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new database with specified security options.

If the securityOptions argument is null then the database will be plain text and accessible from any application.

Parameters:
fileURI - URI of the database file.
securityOptions - Defines optional database security options, such as encryption.
Returns:
Database instance
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

create

public static Database create(URI fileURI,
                              DatabaseSecurityOptions securityOptions,
                              DatabaseOptions databaseOptions)
                       throws DatabaseIOException,
                              DatabasePathException
Creates a new database with specified security options and database options.

If the securityOptions argument is null then the database will be plain text and accessible from any application.

Parameters:
fileURI - URI of the database file.
securityOptions - Defines optional database security options, such as encryption.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

open

public static Database open(URI fileURI)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database.

If the database was encrypted then the caller's module is verified against the code signing key that was used during database creation.

Parameters:
fileURI - URI of the database file.
key - The code signing key for this database.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - If the caller does not have read permission.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

open

public static Database open(URI fileURI,
                            DatabaseOptions databaseOptions)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database with the specified database options.

If the database was encrypted then the caller's module is verified against the code signing key that was used during database creation.

Parameters:
fileURI - URI of the database file.
key - The code signing key for this database.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - If the caller does not have read permission.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

open

public static Database open(URI fileURI,
                            boolean readOnly)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database. Optionally, opens the database in read-only mode (instead of read/write mode). A database file can be opened by multiple read-only database connnections, but it can only be opened by one read/write connection at a time.

If the database was encrypted then the caller's module is verified against the code signing key that was used during database creation.

Parameters:
fileURI - URI of the database file.
readOnly - Open for read-only.
key - The code signing key for this database.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - If the caller does not have read permission.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

open

public static Database open(URI fileURI,
                            boolean readOnly,
                            DatabaseOptions databaseOptions)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database with specified database options. Optionally, opens the database in read-only mode (instead of read/write mode). A database file can be opened by multiple read-only database connnections, but it can only be opened by one read/write connection at a time.

If the database was encrypted then the caller's module is verified against the code signing key that was used during database creation.

Parameters:
fileURI - URI of the database file.
readOnly - Open for read-only.
databaseOptions - Defines optional database options, such as foreign key constraints.
key - The code signing key for this database.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - If the caller does not have read permission.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

open

public static Database open(String id)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database.

Parameters:
id - Database filename using the default root.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

open

public static Database open(String id,
                            DatabaseOptions databaseOptions)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database with specified database options.

Parameters:
id - Database filename using the default root.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

open

public static Database open(String id,
                            boolean readOnly)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database. Optionally, opens the database in read-only mode (instead of read/write mode). A database file can be opened by multiple read-only database connnections, but it can only be opened by one read/write connection at a time.

Parameters:
id - Database filename using the default root.
readOnly - Open for read-only.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

open

public static Database open(String id,
                            boolean readOnly,
                            DatabaseOptions databaseOptions)
                     throws ControlledAccessException,
                            DatabaseIOException,
                            DatabasePathException
Opens an existing database with specified database options. Optionally, opens the database in read-only mode (instead of read/write mode). A database file can be opened by multiple read-only database connnections, but it can only be opened by one read/write connection at a time.

Parameters:
id - Database filename using the default root.
readOnly - Open for read-only.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

openOrCreate

public static Database openOrCreate(String id)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates a plain text database.

Parameters:
id - Database filename using the default root.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

openOrCreate

public static Database openOrCreate(String id,
                                    DatabaseOptions databaseOptions)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates a plain text database with specified database options.

Parameters:
id - Database filename using the default root.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

openOrCreate

public static Database openOrCreate(URI fileURI)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates a plain text database.

Parameters:
fileURI - URI of the database file.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

openOrCreate

public static Database openOrCreate(URI fileURI,
                                    DatabaseOptions databaseOptions)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates a plain text database with specified database options.

Parameters:
fileURI - URI of the database file.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

openOrCreate

public static Database openOrCreate(URI fileURI,
                                    DatabaseSecurityOptions securityOptions)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates a database. If the database doesn't exist then it is created based on the securityOptions parameter.

If the database already exists then its security options remain the same. The securityOptions argument is used only when a new database is created.

Parameters:
fileURI - URI of the database file.
securityOptions - Defines optional database security options, such as encryption. Used only when a database is created.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
IllegalArgumentException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

openOrCreate

public static Database openOrCreate(URI fileURI,
                                    DatabaseSecurityOptions securityOptions,
                                    DatabaseOptions databaseOptions)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates a database with the specified database options. If the database doesn't exist then it is created based on the securityOptions parameter.

If the database already exists then its security options remain the same. The securityOptions argument is used only when a new database is created.

Parameters:
fileURI - URI of the database file.
securityOptions - Defines optional database security options, such as encryption. Used only if the database is created.
databaseOptions - define optional database options, e.g. foreign key constraints
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
IllegalArgumentException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

exists

public static boolean exists(String id)
                      throws DatabasePathException,
                             DatabaseIOException
Checks whether a database already exists by specified ID. Uses the default file system and root location.

Parameters:
id - Database ID.
Returns:
true if the database exists, false otherwise.
Throws:
DatabasePathException - If the default root is invalid or the database ID contains illegal characters.
DatabaseIOException - If the file system cannot be accessed at the moment.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

exists

public static boolean exists(URI uri)
                      throws DatabasePathException,
                             DatabaseIOException
Checks whether a database already exists by specified URI.

Parameters:
uri - Database file URI.
Returns:
true if the database exists, false otherwise.
Throws:
DatabasePathException - If the default root is invalid or the database ID contains illegal characters.
DatabaseIOException - If the file system cannot be accessed at the moment.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

openOrCreate

public static Database openOrCreate(String id,
                                    DatabaseSecurityOptions securityOptions)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates an encrypted database. If the database doesn't exist then it is created based on the securityOptions parameter.

If the database already exists then its security options remain the same. The securityOptions argument is used only when a new database is created.

Parameters:
id - Database filename using the default root.
securityOptions - Defines optional database security options, such as encryption. Used only when the database is created.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
IllegalArgumentException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

openOrCreate

public static Database openOrCreate(String id,
                                    DatabaseSecurityOptions securityOptions,
                                    DatabaseOptions databaseOptions)
                             throws DatabaseIOException,
                                    ControlledAccessException,
                                    DatabasePathException
Opens or creates an encrypted database with specified database options. If the database doesn't exist then it is created based on the securityOptions parameter.

If the database already exists then its security options remain the same. The securityOptions argument is used only when a new database is created.

Parameters:
id - Database filename using the default root.
securityOptions - Defines optional database security options, such as encryption. Used only when the database is created.
databaseOptions - Defines optional database options, such as foreign key constraints.
Returns:
Database instance.
Throws:
DatabaseIOException - On failure.
ControlledAccessException - On access restriction.
DatabasePathException
IllegalArgumentException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 6.0.0

delete

public static void delete(URI fileURI)
                   throws DatabaseIOException,
                          DatabasePathException
Removes an existing database from the device.

Parameters:
fileURI - URI of the database file.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

delete

public static void delete(String id)
                   throws DatabaseIOException,
                          DatabasePathException
Removes an existing database from the device.

Parameters:
id - Database filename using the default root.
Throws:
DatabasePathException
DatabaseIOException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

encrypt

public static void encrypt(String id,
                           DatabaseSecurityOptions securityOptions)
                    throws DatabaseIOException,
                           DatabasePathException
Encrypts a plain text database. This method binds the database to the current device. If the database is already encrypted then the method exits gracefully.

If content protection is turned ON then this operation will succeed only when the device is unlocked.

Parameters:
id - Existing database filename using the default root.
securityOptions - Defines database security options, such as whether protection by code signing key is required.
Throws:
DatabaseIOException
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

encrypt

public static void encrypt(URI fileURI,
                           DatabaseSecurityOptions securityOptions)
                    throws DatabaseIOException,
                           DatabasePathException
Encrypts a plain text database. This method binds the database to the current device. If the database is already encrypted then the method exits gracefully.

If content protection is turned ON then this operation will succeed only when the device is unlocked.

Parameters:
fileURI - URI of the database file.
securityOptions - Defines database security options, such as whether protection by code signing key is required.
Throws:
DatabaseIOException
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

decrypt

public static void decrypt(String id)
                    throws DatabaseIOException,
                           DatabasePathException
Decrypts an encrypted database. This method should be called only when an encrypted database needs to be transferred to another device with further encryption. The database file must be closed before calling this method. If the database is plain text already then the method exits gracefully.

If content protection is turned ON then this operation will succeed only when the device is unlocked.

Parameters:
id - Existent database filename using the default root.
key - The code signing key for this database.
Throws:
DatabaseIOException
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

decrypt

public static void decrypt(URI fileURI)
                    throws DatabaseIOException,
                           DatabasePathException
Decrypts an encrypted database. This method should be called only when an encrypted database needs to be transferred to another device with further encryption. The database file must be closed before calling this method. If the database is plain text already then the method exits gracefully.

If content protection is turned ON then this operation will succeed only when the device is unlocked.

Parameters:
fileURI - URI of the database file.
Throws:
DatabaseIOException
DatabasePathException
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.