|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.database.DatabaseFactory
public class DatabaseFactory
Creates new or opens existing instances of a device 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
1. String path = "/SDCard/MyRoot/Database/MyDB";
2. URI myURI = URI.create(path);
Note: A SD card is the preferred storage for databases, currently Storm and Bold are the devices that can create databases with internal memory.
A database file can be encrypted or plain text. If 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 should be decrypted first. Even though 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 device is unlocked. An encrypted database should be closed as soon as possible. An open database connection is susceptible to cold boot attack.
Note that database may be closed automatically when the file system is unmounted. One such example is when DB file is stored on external media card and user connects the device to a desktop PC and enables USB mass storage mode. In such event, the file system is managed by desktop OS while BlackBerry has no access to it. All the opened databases on external card will be closed and can not be opened until the USB MS mode is finished.
PersistentObject,
DatabaseSecurityOptions| Method Summary | ||
|---|---|---|
|
static Database |
create(String id)
Create a new plain-text database |
|
static Database |
create(String id,
DatabaseSecurityOptions securityOptions)
Create a new database with specified security options. |
|
static Database |
create(URI fileURI)
Create a new plain-text database |
|
static Database |
create(URI fileURI,
DatabaseSecurityOptions securityOptions)
Create a new database with specified security options. |
|
static void |
decrypt(String id)
Decrypts an encrypted database. |
|
static void |
decrypt(URI fileURI)
Decrypts an encrypted database. |
|
static void |
delete(String id)
Removes existing database from the device. |
|
static void |
delete(URI fileURI)
Removes existing database from the device. |
|
static void |
encrypt(String id,
DatabaseSecurityOptions securityOptions)
Encrypts a plain text database. |
|
static void |
encrypt(URI fileURI,
DatabaseSecurityOptions securityOptions)
Encrypts a plain text database. |
|
static boolean |
exists(String id)
Checks whether a database already exists by specified ID. |
|
static boolean |
exists(URI uri)
Checks whether a database already exists by specified URI. |
|
static String |
getDefaultRoot()
Get the default root at which db files are created. |
|
static Database |
open(String id)
Open existing database |
|
static Database |
open(String id,
boolean readOnly)
Open existing database |
|
static Database |
open(URI fileURI)
Open an existing database. |
|
static Database |
open(URI fileURI,
boolean readOnly)
Open an existing database. |
|
static Database |
openOrCreate(String id)
Open or Create a plain-text database |
|
static Database |
openOrCreate(String id,
DatabaseSecurityOptions securityOptions)
Open or create an encrypted database. |
|
static Database |
openOrCreate(URI fileURI)
Open or create a plain-text database |
|
static Database |
openOrCreate(URI fileURI,
DatabaseSecurityOptions securityOptions)
Open or create database. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String getDefaultRoot()
public static Database create(String id,
DatabaseSecurityOptions securityOptions)
throws DatabaseIOException,
DatabasePathException
If securityOptions argument is null then the database will be plain text and accessible from any application.
id - database filename using the default rootsecurityOptions - define optional database security options, e.g. encryption
DatabasePathException
DatabaseIOExceptionDatabaseFactory.create(String)
public static Database create(String id)
throws DatabaseIOException,
DatabasePathException
id - database filename using the default root
DatabasePathException
DatabaseIOException
public static Database create(URI fileURI)
throws DatabaseIOException,
DatabasePathException
fileURI - URI of the database file
DatabasePathException
DatabaseIOException
public static Database create(URI fileURI,
DatabaseSecurityOptions securityOptions)
throws DatabaseIOException,
DatabasePathException
If securityOptions argument is null then the database will be plain text and accessible from any application.
fileURI - URI of the database filesecurityOptions - define optional database security options, e.g. encryption
DatabasePathException
DatabaseIOException
public static Database open(URI fileURI)
throws ControlledAccessException,
DatabaseIOException,
DatabasePathException
If database was encrypted then the caller's module is verified against the code signing key that was used during database creation.
fileURI - URI of the database filekey - The code signing key for this database
DatabaseIOException - on failure
ControlledAccessException - Thrown if the caller does not have read permission
DatabasePathException
public static Database open(URI fileURI,
boolean readOnly)
throws ControlledAccessException,
DatabaseIOException,
DatabasePathException
If database was encrypted then the caller's module is verified against the code signing key that was used during database creation.
fileURI - URI of the database filereadOnly - open for read-onlykey - The code signing key for this database
DatabaseIOException - on failure
ControlledAccessException - Thrown if the caller does not have read permission
DatabasePathException
public static Database open(String id)
throws ControlledAccessException,
DatabaseIOException,
DatabasePathException
id - database filename using the default root
DatabaseIOException - on failure
ControlledAccessException - on access restriction
DatabasePathException
public static Database open(String id,
boolean readOnly)
throws ControlledAccessException,
DatabaseIOException,
DatabasePathException
id - database filename using the default rootreadOnly - open for read-only
DatabaseIOException - on failure
ControlledAccessException - on access restriction
DatabasePathException
public static Database openOrCreate(String id)
throws DatabaseIOException,
ControlledAccessException,
DatabasePathException
id - database filename using the default root
DatabaseIOException - on failure
ControlledAccessException - on access restriction
DatabasePathException
public static Database openOrCreate(URI fileURI)
throws DatabaseIOException,
ControlledAccessException,
DatabasePathException
fileURI - URI of the database file
DatabaseIOException - on failure
ControlledAccessException - on access restriction
DatabasePathException
public static Database openOrCreate(URI fileURI,
DatabaseSecurityOptions securityOptions)
throws DatabaseIOException,
ControlledAccessException,
DatabasePathException
Note that if database already exists then its security options remain the same. The securityOptions argument is used only when a new database is created.
fileURI - URI of the database filesecurityOptions - defines optional database security options, e.g. encryption, used only if database is being created
DatabaseIOException - on failure
ControlledAccessException - on access restriction
DatabasePathException
IllegalArgumentException
public static boolean exists(String id)
throws DatabasePathException,
DatabaseIOException
id - database ID
DatabasePathException - if default root is invalid or database ID contains
illegal characters
DatabaseIOException - if file system can not be accessed at the moment
public static boolean exists(URI uri)
throws DatabasePathException,
DatabaseIOException
uri - database file URI
DatabasePathException - if default root is invalid or database ID contains
illegal characters
DatabaseIOException - if file system can not be accessed at the moment
public static Database openOrCreate(String id,
DatabaseSecurityOptions securityOptions)
throws DatabaseIOException,
ControlledAccessException,
DatabasePathException
Note that if database already exists then its security options remain the same. The securityOptions argument is used only when a new database is created.
id - database filename using the default rootsecurityOptions - defines optional database security options, e.g. encryption, used only if database is being created
DatabaseIOException - on failure
ControlledAccessException - on access restriction
DatabasePathException
IllegalArgumentException
public static void delete(URI fileURI)
throws DatabaseIOException,
DatabasePathException
fileURI - URI of the database file
DatabasePathException
DatabaseIOException
public static void delete(String id)
throws DatabaseIOException,
DatabasePathException
id - database filename using the default root
DatabasePathException
DatabaseIOException
public static void encrypt(String id,
DatabaseSecurityOptions securityOptions)
throws DatabaseIOException,
DatabasePathException
If content protection is turned ON then this operation will succeed only when device is unlocked.
id - existent database filename using the default rootsecurityOptions - defines database security options, e.g. whether protection by code signing key is required
DatabaseIOException
DatabasePathException
public static void encrypt(URI fileURI,
DatabaseSecurityOptions securityOptions)
throws DatabaseIOException,
DatabasePathException
If content protection is turned ON then this operation will succeed only when device is unlocked.
fileURI - URI of the database filesecurityOptions - defines database security options, e.g. whether protection by code signing key is required
DatabaseIOException
DatabasePathException
public static void decrypt(String id)
throws DatabaseIOException,
DatabasePathException
If content protection is turned ON then this operation will succeed only when device is unlocked.
id - existent database filename using the default rootkey - The code signing key for this database
DatabaseIOException
DatabasePathException
public static void decrypt(URI fileURI)
throws DatabaseIOException,
DatabasePathException
If content protection is turned ON then this operation will succeed only when device is unlocked.
fileURI - URI of the database file
DatabaseIOException
DatabasePathException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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.