我有一个使用phonegap编写的应用程序,我想在我的应用程序第一次加载时创建表和数据并在数据库中插入,但是每次运行我的应用程序时,再次插入数据,加载时间增加,如果表创建了如何检查不再插入数据?
document.addEventListener("deviceready", onDeviceReady, false);
var dbShell ;
function onDeviceReady() {
dbShell = window.openDatabase("BaharNarenj", "1.0", "BaharNarenj", 2000000);
dbShell.transaction(setupTable,dbErrorHandler,getEntries);
}
function setupTable(tx){
tx.executeSql("CREATE TABLE IF NOT EXISTS amaken(id INTEGER,title,des,px,py)");
tx.executeSql('insert into amaken(id,title,des,px,py) values(2,"test","dec","36.566185","55.059502")');
tx.executeSql('insert into amaken(id,title,des,px,py) values(4,"test5","dec5","36.566185","55.059502")');
}
function dbErrorHandler(err){
alert("DB Error: "+err.message + "\nCode="+err.code);
}
function getEntries() {
alert("done");
}