Thursday, March 15, 2012

HTML5 openDatabase()

Today we hit a bit of a snag during device testing a new Blackberry App using a HTML5 SQLLite database.

Code that was working fine in Chrome (which we use to test prior to device testing) - failed the moment that we bundled it and loaded it onto a brand new Blackberry 9860.

For the life of us we could not figure out why we were getting the error: SECURITY_ERR: DOM Exception 18

Every forum post we could find suggested the same two things.

1. Make sure that you are not opening your database with a size any bigger than 5Mb. SQLLite has a maximum size of 5Mb and will fail to open if you try and set the size any bigger.

2. Ensure that you have an SD card in the device - this is also needed for the window.openDatabase() command to work.

Both of these points were not a problem, taking the back off the device it was obvious that there was an SD card inside - we even checked to make sure that there was space on it and saved a picture to it ensuring that it worked properly.

A quick code check also showed we were opening the database with an expected size of just 1Mb, well inside the limit.

So back to square one, running through everything for a second and third time frustrating was really setting in. Eventually after nearly two hours repetitive testing we found the problem, completely by accident.

In a moment of frustration we unplugged the device from the USB cable connecting it to the work station and took it to a colleague for a spot of ranting. Imagine our surprise when we fired up the App hoping to demonstrate it NOT working only for the device to load the App and create the database faultlessly.

No code changes. The only thing changed was taking the device off the USB - and that it seems is the problem. Going back to the desk and plugging the device back in everything becomes clear...

We we're loading the App onto the device using the Blackberry Desktop Application and it seems then when the device is connected via a USB, which is needed for the Blackberry Desktop Application to work, that the SD card is not recognised by the device. Seriously, once you disconnect the device the card is recognised once more and your code will work.

No comments:

Post a Comment