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
Contributor
binnyb
Posts: 19
Registered: ‎11-02-2010
My Device: Not Specified

creating sqlite database with google gears. widget sdk

I have a JavaScript function named "openDatabase()" that starts with:

 

 

function openDatabase() {
   try {
       _db = google.gears.factory.create('beta.database');
      ...//more code
  }
  catch(err) {
     alert(err.name + " " + err.message);
  }
i have created my sqlite database with success running on the simulators for the Bold 9700 and Storm 2 9550.  When i deploy this same app to a real device(the new torch), an exception is caught with err.name "ReferenceError" and err.message "Can't find variable: google"
why doesn't it know what google is? i am importing these javascript files: 
<script type="text/javascript" src="scripts/html5_init.js"></script>
<script type="text/javascript" src="scripts/gears.js"></script>

 

Please use plain text.
Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: creating sqlite database with google gears. widget sdk

Hi binnyb,

 

Gears was only supported on BlackBerry 5.0 devices. On BlackBerry 6 we now support HTML5 objects that replace the Gears functionality.

 

We have also provided an HTML5 JavaScript toolkit that will allow you to write your code once for HTML5 and it will work both on BlackBerry 5.0 and BlackBerry 6 by simply including the toolkit.  It will also be forward compatible with the BlackBerry PlayBook.

 

Instructions can be found here:

 

http://supportforums.blackberry.com/t5/Web-Development/Supporting-Gears-using-HTML5-in-BlackBerry-Wi...

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300

Re: creating sqlite database with google gears. widget sdk

Something extra you might want to be aware of....

 

rename your function openDatabase to something else... it conflicts with the WebSql function that opens a created database. I ran into this issue on my side.

 

 

Just include the HTML5_init.js and use the Web SQL syntax for created a DB. It will work on both OS 5 and OS 6 devices.

 

 

function openDB() {
  var dbSize = 1 * 1024 * 1024; //1MB
  var db = openDatabase("testDB","1.0",testDB",dbSize);
  if (db) {
     db.transaction(function(tx){
        tx.executeSql("CREATE TABLE IF NOT EXISTS testTable (Name, PhoneNum)");
     });
  }
}

 

 

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.