2
我有一個應用程序用phonegap編寫,我希望當我的應用程序加載時,表和數據創建並插入數據庫,但每次運行我的應用程序時,插入數據再次完成,加載時間增加,如果表創建不再插入數據,怎麼辦?在第一次加載應用程序時在phonegap中的sqlite數據庫中插入數據
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");
}
電話中沒有SharedPreference? –