02-08-2010 11:53 PM - last edited on 02-09-2010 09:57 AM
I've looked at the developer blog post and the gears code examples, but for some reason my widget can't get past my create table statements below. I've even tried simplifying it, but still no luck. My code never makes it past the first create table below. Any ideas what I am missing? (I have the gears_init.js in my project)
// Open the database using Google Gears API and create tables if needed
function openDatabase()
{
alert("inside of openDatabase");
var db = google.gears.factory.create('beta.database');
alert("after create db");
db.open('Emit-database');
alert("after open db");
db.execute('create table if not exists Station (Name, StationID)');
//db.execute('create table if not exists Station (Name, StationID, SiteID, CanPoll, IsSatellite, Lat, Lon, PropID, API)');
alert("after create table Station");
db.execute('CREATE TABLE IF NOT EXISTS StationData (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, StationID , DataString)').close();
_db = db;
}
02-09-2010 09:14 AM
Hello,
This may be expected behaviour, depending on which BlackBerry Smartphone model you are using.
There is currently a design limitation with the underlying SQLite API used to implement the Gears DB. The file system type of the internal memory on a BlackBerry Smartphone is not compatible with SQLite. As a result, this API requires that the device has either eMMC or an SDCard. This design limitation affects Java applications as well.
More details about this behaviour can be found here:
http://www.blackberry.com/developers/docs/widgetap
Sincerely,
Adam
02-09-2010 09:45 AM - last edited on 02-09-2010 09:52 AM
Hello Adam,
I am trying to simulate this code on the 9550 simulator packaged with the Widget Beta 3.
02-09-2010 12:33 PM
Hi jmace,
You will have to turn on SD card emulation in the Simulator.
This can be done via the "Simulate -> Change SD Card..." menu item in the simulator. You can choose a directory on your file system you would like the simulator to use as the root of your SD card.
02-09-2010 02:40 PM
So does this mean that a DB used/created by gears must be stored on the SD card?
02-09-2010 03:04 PM
I've added a piece of code to check if gears is even registering. I am hitting the alert for "Gears not initialized".
In my index.html, I have a reference to gears_init.js. Am I missing something else? I've also added an SD card file to the simulator as suggested.
// Open the database using Google Gears API and create tables if needed function openDatabase(){
alert("inside of openDatabase");
var db = google.gears.factory.create('beta.database');
if (!window.google || google.gears)
{
alert("Gears not initialized");
}
alert("after create db");
db.open('Emit-database');
alert("after open db");
db.execute('create table if not exists Station (Name, StationID)');
//db.execute('create table if not exists Station (Name, StationID, SiteID, CanPoll, IsSatellite, Lat, Lon, PropID, API)');
alert("after create table Station");
db.execute('CREATE TABLE IF NOT EXISTS StationData (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, StationID , DataString)').close();
_db = db;
}
02-09-2010 04:05 PM
mikeo007 wrote:
So does this mean that a DB used/created by gears must be stored on the SD card?
A BlackBerry smartphone must either have an SD card present or have a built in eMMC card for the Gears Database
02-09-2010 10:38 PM
> I've added a piece of code to check if gears is even registering. I am hitting the alert for "Gears not initialized".
That's because !a || b evaluates as (!a) || b. When b is "google.gears", that expression will return true if gears is installed.
02-10-2010 08:42 AM
yes Stak,
I noticed that and had already changed that if statement. proceeding with
if (!window.google)
alert("Gears uninitialized");
Regardless, the code still fails on the db.execute create table statement and throws an 'undefined' error when this is all placed in a try catch.
02-10-2010 09:26 AM
You had mentioned that you had the gears_init.js in your project, but is it also loaded into the page via a <script> tag where you are writing your gears code?