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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Contributor
Posts: 8
Registered: ‎03-23-2011
My Device: developer
My Carrier: developer

copy a SQLite db in JavaScript



I would like to do read pre-loaded data and display it on an html page, something very simple

But how can I copy the database from the installation directory to the storage directory. The example I found is for Java.

var origDB : File = File.applicationDirectory.resolvePath("db1.sqlite" );   
var destDB
: File = File.applicationStorageDirectory.resolvePath("db1.sqlite");

My understanding is that I have to do the above to read the sqlite db.

How can I do it in JavaScript ?


Thank you



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
<title>Database test</title>
<script type="text/javascript">
 function startapp() {


        var origDB : File = File.applicationDirectory.resolvePath( "db.sqlite" );
   //      var destDB : File = File.applicationStorageDirectory.resolvePath("db.sqlite");
  //       origDB.copyTo(destDB);
   catch ( Error )
      alert ( Error );

//just hardcoded the results to make sure the html file works

  var buffer = "";
  for ( var i = 0; i < 4; i++) {
   //Create a div to insert into the results
   var aDiv = document.createElement("div");

   // This part where you want to process the result and wrap it with HTML tag
   buffer += '<p>Loop iteration: ' + (i+1) + '<br />';
            buffer += 'Customer name: ' + 'current.NAME1' + '<br />';
            buffer += 'Customer address: ' + 'current.ADDRESS1' + '<br />';
            buffer += 'Customer phone: ' + 'current.PHONE</p>';
   aDiv.innerHTML = buffer;

   buffer = "";  

<body onload="startapp()">
 <div id="resultContent"></div>

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

Re: copy a SQLite db in JavaScript

If you're using WebWorks, you should be asking in the Web Development forum instead.


If you're using AIR, you should do the copying using ActionScript3 (it's not Java... I guess that was just a typo) as you showed in your post.


JavaScript does not have access to the filesystem that way, as far as I know, at least not yet.  I seem to recall that even the Web Works environment doesn't expose filesystem access to you yet, though that might have changed in the most recent SDK.  (I'm not a Web Works user.)

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!