我正在使用 jquery mobile、SQlite 数据库、Cordova
当我的应用程序关闭时,请帮助我,然后当我打开我的应用程序时,即使我的数据库已创建,它也将成为我的first.js文件的其他部分,并再次创建数据库
我的 JQuery 脚本:-
我正在使用两个脚本
第一个.js
if(db){
// Database is going to update.
alert("Database exist");
userAuthentication();
}else{
DB_Create();
alert("database created");
userAuthentication();
}
第二个.js
//全局变量
var db;
var short_Name = 'E_DB';
var version = '1.0';
var display_Name = 'E_DB';
var max_Size = '65535';
var flags = true;
userAuthentication(){
if(flags){
flags=false;
alert("hello");
}else{
alert("hi");
}
}
DB_Create(){
db = window.openDatabase(short_Name, version, display_Name, max_Size);
db.transaction(function(transaction) {
transaction.executeSql('DROP TABLE IF EXISTS Out');
transaction.executeSql('CREATE TABLE IF NOT EXISTS Out(id INTEGER PRIMARY KEY AUTOINCREMENT)');
});
}
最佳答案
在 deviceReady 中创建数据库并在需要时调用 userAuthentication 可能会解决您的问题。
关于jquery - 应用程序再次关闭我打开我的应用程序它再次创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20089952/