【发布时间】:2013-06-19 08:44:47
【问题描述】:
我有一个使用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");
}
【问题讨论】:
-
phonegap中没有SharedPreference吗?