Welcome!

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

Reply
Developer
Posts: 119
Registered: ‎03-10-2010
My Device: Bold 9000
My Carrier: Rogers
Accepted Solution

Playbook database API

Does playbook OS have a built-in database? Like SQLite? How about APIs?

 

Thanks

 

 



(*) Kudo-me if you really think I helped you!
My plug: I'm doing a Mobile Experiment, reported on my Blog: Check it out!.
---------------------------
Paulo Garcia
http://www.mobilecreators.com - Twitter: http://twitter.com/mobilecreators
Highlighted
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Playbook database API

Not at the OS level, but at the Flash/AIR level.  Lots of documentation and examples on SQLite, but here is the adobe documentation on it.

 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/package-detail.html

 

 

Developer
Posts: 119
Registered: ‎03-10-2010
My Device: Bold 9000
My Carrier: Rogers

Re: Playbook database API

Thanks!



(*) Kudo-me if you really think I helped you!
My plug: I'm doing a Mobile Experiment, reported on my Blog: Check it out!.
---------------------------
Paulo Garcia
http://www.mobilecreators.com - Twitter: http://twitter.com/mobilecreators
Contributor
Posts: 18
Registered: ‎04-01-2008
My Device: Not Specified

Re: Playbook database API

Hi Guys,

i am pretty new with the usge of database. I would like to dev a simple note app using database has refrence id for each notes.

 

do you have some example or tuto step by step?

 

 

Developer
Posts: 157
Registered: ‎12-16-2010
My Device: Torch 9800, PlayBook
My Carrier: I carry it myself

Re: Playbook database API

 


Dani78112 wrote:

Hi Guys,

i am pretty new with the usge of database. I would like to dev a simple note app using database has refrence id for each notes.

do you have some example or tuto step by step?


 

Hey - I am working on notes app too ;-) welcome to the club...

 

here is sample AS3 code to get you started. 

 

 

import flash.filesystem.File;
import flash.data.*;
var myDB:File = File.applicationStorageDirectory.resolvePath("mydatabase.db");
var sqlConn:SQLConnection = new SQLConnection();
var sqlStatement:SQLStatement = new SQLStatement();
sqlConn.open(myDB);
sqlStatement.sqlConnection = sqlConn;
sqlStatement.text = "SELECT * FROM table1";
sqlStatement.execute();
var result:Array = sqlStatement.getResult().data;

 The "result"variable is an array with the result of the query where each array member is an object where value of a column is a property with the name of the column.

 

You can also set itemClass property on the sqlStatement to particular object class and the array objects will be returned of the type of the object you specify in the itemClass as long as the DB column names match the object properties. Its pretty exciting stuff ;-) 

 

Hope this gets you going.

 

----------
If you find this post helpful please "like" it and accept as a solution.
Contributor
Posts: 18
Registered: ‎04-01-2008
My Device: Not Specified

Re: Playbook database API

hello, thanks for this, I'll try it soon.

 

Smiley Happy

Contributor
Posts: 14
Registered: ‎12-23-2010
My Device: Playbook

Re: Playbook database API


p3pp3r wrote:

 


Dani78112 wrote:

Hi Guys,

i am pretty new with the usge of database. I would like to dev a simple note app using database has refrence id for each notes.

do you have some example or tuto step by step?


 

Hey - I am working on notes app too ;-) welcome to the club...

 

here is sample AS3 code to get you started. 

 

 

import flash.filesystem.File;
import flash.data.*;
var myDB:File = File.applicationStorageDirectory.resolvePath("mydatabase.db");
var sqlConn:SQLConnection = new SQLConnection();
var sqlStatement:SQLStatement = new SQLStatement();
sqlConn.open(myDB);
sqlStatement.sqlConnection = sqlConn;
sqlStatement.text = "SELECT * FROM table1";
sqlStatement.execute();
var result:Array = sqlStatement.getResult().data;

 The "result"variable is an array with the result of the query where each array member is an object where value of a column is a property with the name of the column.

 

You can also set itemClass property on the sqlStatement to particular object class and the array objects will be returned of the type of the object you specify in the itemClass as long as the DB column names match the object properties. Its pretty exciting stuff ;-) 

 

Hope this gets you going.

 


Hi p3pp3r,

I don't need this, but would like to know more. Would the DB be a CSV file?

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Playbook database API

[ Edited ]

 


amycanada wrote:

I don't need this, but would like to know more. Would the DB be a CSV file?


It's a SQLite database, not a CSV text file.  See the docs for flash.data or (linked to from that page) SQL support in local databases.

 

 

For those new to any of this, you'll be most efficient if you start off with SharedObject.  It has limitations, but for your first attempts it will get you farther faster.  It's also probably the best for any simple data, especially app settings/preferences.

 

Migrate from that to flash.filesystem stuff to learn how to work with local files.  You can layer XML on top of that if you're familiar with it, or other means of encoding (e.g. JSON).  Using this with CSV is also a good option for many moderate needs involving tabular data.

 

Lastly, and only when it's really worth your while, move up to the database stuff.  It can be very efficient, and flexible, and is the most powerful for "relational" information (multiple inter-related tables).  It can also have significant disadvantages not the least of which is the learning curve.  If you need its power then you may have little choice in the matter, but I'd suggest this is an area where you should learn to walk before you try to run.

 

(Edit: fixed bad link to sqlite.org.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Playbook database API

Sorry for the bad link to SQLite.  The one I first included is an unused domain.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 14
Registered: ‎12-23-2010
My Device: Playbook

Re: Playbook database API

Hi Peter9477,

 

Thanks! I'm very familiar with MS SQL Server, but I didn't know there was anything similar that could be used with Flash...

That's good to know.