• BlackBerry Dynamics
  • Runtime library for Android applications
Package com.good.gd.database

Secure SQL database. More...


The secure SQL database is part of the BlackBerry Dynamics secure storage feature.

Data stored in the secure SQL database will be encrypted on the device by the BlackBerry Dynamics runtime.

The BlackBerry Dynamics secure SQL database is based on the SQLite library. Encryption is added by BlackBerry Dynamics, transparently to the application.

The secure SQL database cannot be accessed until BlackBerry Dynamics authorization processing is complete.

As well as the secure SQL database, the BlackBerry Dynamics secure store also includes a secure file system.

See also
GDAndroid, for BlackBerry Dynamics authorization
BlackBerry Dynamics File I/O Package
http://www.sqlite.org/, the home page of the SQLite project.

Overview of the programming interface

BlackBerry Dynamics applications access the secure database using replacements for the native android.database and android.database.sqlite packages.

To access the replacement classes instead of the native classes, change android.database to com.good.gd.database wherever it occurs in the application code. For example, utilize the following import statement.

import com.good.gd.database.sqlite.SQLiteDatabase;

The replacement packages support the same programming interface as the native packages, with the following exceptions.

  • The LOCALIZED and UNICODE collators provided by the native android.database.sqlite package aren't supported.
  • There is an additional function, importDatabase, see below.
  • Paths of database files are interpreted relative to the root of the BlackBerry Dynamics secure file system of the application. The root of the secure file system is within the application's data directory. This means that there is no need to utilize functions such as the native getFilesDir to generate database file paths.
See also
android.database and android.database.sqlite package documentation on the android.com developer website.

Additional Functions

public static boolean importDatabase(String srcPath, String destPath)
Use this function to create an encrypted database from a plain SQLite database file. The database file must be in the secure file system, see BlackBerry Dynamics File I/O Package.

After a succesful import, the database can be opened using the openDatabase method in the android.database.SQLiteDatabase class.

This function would typically be used on an SQLite database that had been retrieved as a single file from an application server.

This function can only be called after BlackBerry Dynamics authorization processing is complete, see under GDAndroid.

srcPath path, within the secure file system, of the plain SQLite database file to be imported.
destPath database to be created. If the database already exists, its contents will be overwritten.
On success, true is returned.
Otherwise false is returned.

Code Snippets

The following code snippets illustrate some common tasks.

Open database

import com.good.gd.database.sqlite.SQLiteDatabase;
SQLiteDatabase dbInstance = SQLiteDatabase.openOrCreateDatabase(

The above snippet shows opening the database in the contacts.db file in the secure file system. The database is created if it does not exist already.