我正在使用HTML5,JS,CSS构建混合应用程序 . 在这个应用程序中,我正在使用SQLite插件,以便可以在Android设备中存储500 MB的数据(主要是选项卡) . 该数据将由应用程序从后端服务器提取,并在应用程序脱机时可供用户使用 . 作为第一步,应用程序设计很简单,第一步是让SQLite插件正常工作 . 到目前为止,我已经完成了以下步骤来实现SQLite插件:
-
创建cordova项目并使用cordova插件添加插件添加io.litehelpers.cordova.sqlite
-
在deviceready函数中,我使用了openDatabase函数 . 但是,我的代码在进入如下所示的DeviceReady函数时停止工作:
document.addEventListener(“deviceready”,onDeviceReady,false);
function onDeviceReady(){
alert("On deviceready function called");//This alert is triggered
var db = window.sqlitePlugin.openDatabase({name: "StoreTest.db"});//*****Code Execution STOPS from this line*****
db.transaction(createTable, errorInCreate, successInCreate);
function createTable(tx){
alert("in createTable");//This alert is not triggered meaning the code is not executed
tx.executeSql('DROP TABLE IF EXISTS TestImages');
tx.executeSql('CREATE TABLE IF NOT EXISTS TestImages(imgdata TEXT)');
}
function errorInCreate(){
alert("Error creating table: ");//+JSON.stringify(e));
}
function successInCreate(){
alert("success creating table");
}
}
我已经为SQLite插件引用了以下链接:
https://github.com/litehelpers/Cordova-sqlite-storage
http://www.thecreativedev.com/how-to-use-sqlite-database-in-phonegap/
应用程序将在iOS和Android中使用 .
任何人都可以帮助找到使用SQLite插件的错误?
谢谢,Abhishek .