Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database undefined error in phonegap android?

I am getting database: undefined in phonegap with android. I am creating some tables in phonegap and after successful creation of tables it gives me the database undefined error. please help. i am new to phonegap. code -

var db; 
var dbCreated = false; 
document.addEventListener("deviceready", onDeviceReady, false); 
function onDeviceReady() { 
  //alert("In Device Ready..."); 
  db = window.openDatabase("sgpw", "1.0", "PhoneGap Demo", 200000); 
  db.transaction(populateDB, transaction_error, populateDB_success); 
}
like image 237
Shailesh Thanki Avatar asked Feb 14 '12 11:02

Shailesh Thanki


1 Answers

I got same problem when was new to phonegap. Try this ,

var db = window.openDatabase("sgpw", "1.0", "PhoneGap Demo", 200000); 

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() { 

db.transaction(populateDB, transaction_error, populateDB_success);

}

This will then call populateDB function.
If error comes then will call transaction_error.
If successful then will call populateDB_success function.

like image 137
Dhruvisha Avatar answered Sep 28 '22 10:09

Dhruvisha