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

Web and WebWorks Development

Reply
New Contributor
cstepaniuk
Posts: 4
Registered: ‎05-16-2012
My Device: Playbook
My Carrier: NA

Playbook: choosing a database for field data collection

Hi,

 

I need to pick an underlying method of saving data collected in the field (offline and remote locations).  I want to use the HTML5 Database with SQLite but I can I pick the location?  So far, I haven't been able to accomplish that.  Here is some sample code I was using:

 

var dbName = "";

var Dir = blackberry.io.dir;
var path = Dir.appDirs.shared.documents.path;
dbName = path + "/" + "databasetest.db"; 

 

var db = openDatabase(dbName, '1.0', 'Test', 50 * 1024);

 

I used an "alert()" to see the file was "supposedly" created, but when I opened the folder in Explorer I cannot find it.  Not really sure why and hense my question.

 

My application is for data entry, without getting into specifics, user may end up collecting a lot or little data.  But I want some way of downloading the SQLite database?

 

Is this the intention of the SQLite database, or will I have to use another solution?

 

Thanks!

Chris

Please use plain text.
Developer
jamesgibbons
Posts: 26
Registered: ‎06-01-2010
My Device: Dev Alpha, PlayBook

Re: Playbook: choosing a database for field data collection

Hi Chris,

 

The database you created on PlayBook should be in the folder: /accounts/1000/appdata/<appname>/data/database/local_0/. You can view the .db file by installing and setting up Blackberry-Connect. The database name will not be dbName.db, but will be in the format 0000000<database number>.db, where 00000001.db would be the first database you created.

 

However, you shouldn't have to worry about the phsyical database implementation and I think you are on the right track. You just need to setup a local database on the device as you have done. Then, make an AJAX GET request to the server and use a for loop to insert the records from the server into your database on the PlayBook. To send the local contents of the database back to your server you can send an AJAX POST request. Depending on the amount of syncronization you need to do, you could check out this stackoverflow answer to guide you:

http://stackoverflow.com/questions/1744522/best-way-to-synchronize-local-html5-db-websql-storage-sql....

 

If you run into problems and aren't sure about the state of your database, open up Chrome's debugging tools (Control shift i), choose the tab "Resources" and click on "Web SQL" in order to view your database tables.

 

Hope this helps,

 

James

___________________________________________________________
My latest Blackberry 10 app Audiobooks! :smileyhappy:

My latest PlayBook app Photojam!

Find me on Twitter: GoGibbons
Please use plain text.
New Contributor
cstepaniuk
Posts: 4
Registered: ‎05-16-2012
My Device: Playbook
My Carrier: NA

Re: Playbook: choosing a database for field data collection

Hi,

 

I've heard of the BlackBerry Desktop Software but not "Blackberry-Connect", is that something new?  Do you have a download link, maybe I'm missing something.

 

Not sure if the AJAX GET/POST approach is best, and I do not have wifi where I am.  Corporate policy.  I have a mini-usb cable, it all must be doen through that.  I guess that means AJAX is a no-go.  I know what you are getting at, I'm just in a tighter sandbox than most developers.

 

I'll take a look at the sync libraries and see what fits my needs.  I do like the idea of copying the database out to local storage and seeing how that works.

 

Thanks!

Chris

Please use plain text.
Developer
jamesgibbons
Posts: 26
Registered: ‎06-01-2010
My Device: Dev Alpha, PlayBook

Re: Playbook: choosing a database for field data collection

Blackberry-Connect is separate from Blackberry Desktop software. It is just a way of connecting to the PlayBook and obtaining SSH access. It is included in the Blackberry Tablet SDK. (http://openbbnews.wordpress.com/2011/12/21/devuser-and-1000/). For most things you shouldn't need to worry about setting it up.

 

HTML5 local storage or WebSQL should work fine for your use case!

 

Cheers,

 

James

___________________________________________________________
My latest Blackberry 10 app Audiobooks! :smileyhappy:

My latest PlayBook app Photojam!

Find me on Twitter: GoGibbons
Please use plain text.