Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Using Persistence Store via SQLite Database

by Retired on ‎05-26-2011 02:21 PM (4,283 Views)

All applications running on the BlackBerry® PlayBook™ tablet run within their own sandbox. This security model, prevents Adobe® AIR® applications from interacting with each other's sandbox. Therefore when a db file is created within the application storage directory "<appname>/app/", other applications do not have read/write permissions to that db file.

For persistance data to be readily accessed by other applications outside the application sand box, the data can be stored via "<appname>/shared/misc" which is a public directory. Hence, when databases are being created, they can either be private by storing it within the application storage directory, or be made public by storing it within a shared public directory.


Users must grant your application access to the folders within the shared directory. To request access, you will need to include the following snippet in your blackberry-tablet.xml file. 


More info in regards to gaining access to APIs that have limited functionaliy, please see
 Accessing restricted functionality.


The main method for establishing, opening and querying a database is as follows:


  • new SQLConnection():void - Calling the connection constructure, to open a new connection.
  • open():void or openAsync():void - Open a connection to a database file at the specified location in the file system.
  • execute():void  - Executes the SQL query against the database that is connected to the SQLConnection object.
The following snippets of code illustrates how you can establish a connection and conduct transcations of a database:

Creating a SQLite connection:

// Creating a connection private var sqlConSmiley FrustratedQLConnection = new SQLConnection();


Creating a database File:

private var employeeDB:File; // Path to a database file employeeDB = File.applicationStorageDirectory.resolvePath('employee.db');


Opening the database:


// Opening the file Asynchronously
sqlCon.addEventListener(SQLEvent.OPEN, openDB);


Linking the query Object to the database connection:


private var query:SQLStatement = new SQLStatement();

// Linking the statement to the sqlConnection
query.sqlConnection = sqlCon;


Creating a table and executing the query:


query.text = "CREATE TABLE IF NOT EXISTS employee_table" +
"( id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT, email TEXT, " +
" position TEXT, company TEXT, department TEXT, phone TEXT, country TEXT);";

// Executing the query.


See the following learning resources for more information on the API used in this article:



The following attached Contact List example illustrates how to use databases.

Adobe® AIR®

Users Online
Currently online: 24 members 2,391 guests
Please welcome our newest community members: