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 Developer
Posts: 17
Registered: ‎05-20-2010
My Device: Passport
My Carrier: AT&T
Accepted Solution

SQLite Through WebWorks?

I am attempting to create a SQLite Database for local storage on the PlayBook. However the database comes up as undefined. 

 

Is it possible to do this and if so how.

 

var db = window.openDatabase("Database", "1.0", "Database", 200000);


function initializeDB()
{
 
 db.transaction(function (tx)

{
   tx.executeSql("CREATE TABLE IF NOT EXISTS table(Id INTEGER, Name)");
   tx.executeSql("INSERT INTO ListName(Id,Name) VALUES (1,'default')");
 });
 
 db.transaction(function (tx) {
   tx.executeSql('SELECT * FROM table', [], function (tx, results) {
    var len = results.rows.length, i;

    for (i = 0; i < len; i++){
   $('#div').append('<li><a href="#">Found rows: ' + results.rows.item(i).Name + '</a></li>');
    }
  }, null);
 });

}

 

This works in Chrome but not in FireFox or on the PlayBook.

Creator of Todomate for BlackBerry 10 | follow me on twitter @lchampagnie
Developer
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: SQLite Through WebWorks?

Give this a shot and see what happens

 

try
   {
      var dbSize = 1 * 1024 * 1024;
      db = openDatabase("Mydb", "1.0", "Mydb", dbSize);
   }
   catch ( Error )
   {
      alert ( Error );
   }

 

New Developer
Posts: 17
Registered: ‎05-20-2010
My Device: Passport
My Carrier: AT&T

Re: SQLite Through WebWorks?

I guess i was not reserving enough space for the database so it never got created.

 

Thanks for the assistance.

Creator of Todomate for BlackBerry 10 | follow me on twitter @lchampagnie
Developer
Posts: 213
Registered: ‎10-02-2010
My Device: Z10 and Z30
My Carrier: Play and Plus

Re: SQLite Through WebWorks?

If you still have problems with database look into my sample application https://github.com/ddluk/WebWorks-Database

New Developer
Posts: 17
Registered: ‎05-20-2010
My Device: Passport
My Carrier: AT&T

Re: SQLite Through WebWorks?

Thanks ddluk,

 

I got it to work fine on the Playbook Sim and in Chrome. But for some reason this doesn't seem to work on FireFox 3.5 or FireFox 4.

 

Not Quite sure why.

Creator of Todomate for BlackBerry 10 | follow me on twitter @lchampagnie
Highlighted
New Contributor
Posts: 4
Registered: ‎03-19-2011
My Device: Playbook
My Carrier: Sprint

Re: SQLite Through WebWorks?

It doesnt work in FF because FF doesnt support SQLite at the moment, similar to IE