从适用于android的phonegap html文件连接到sqlite数据库
我正在使用phonegap和sqlite为android、ios和blackberry开发跨平台的移动应用程序。我正在使用它们作为参考。下面是我的index.html 1.我在lib中有phonegap.jar 2.got phonegap.js在assests/ww中 3.在我的硬盘中下载了sqlite浏览器和sql shell 4.got jquery.min.js 我想知道如何从index.html中给出我的sqlite的位置,以便它可以与它建立连接。如果我只是传入phonegap.js,它就不会连接到sqlite从适用于android的phonegap html文件连接到sqlite数据库,android,sqlite,mobile,cordova,Android,Sqlite,Mobile,Cordova,我正在使用phonegap和sqlite为android、ios和blackberry开发跨平台的移动应用程序。我正在使用它们作为参考。下面是我的index.html 1.我在lib中有phonegap.jar 2.got phonegap.js在assests/ww中 3.在我的硬盘中下载了sqlite浏览器和sql shell 4.got jquery.min.js 我想知道如何从index.html中给出我的sqlite的位置,以便它可以与它建立连接。如果我只是传入phonegap.js,
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="js/phonegap-1.4.0.js"> </script>
<script type="text/javascript" src="js/jquery.min.js"/></script>
<script type="text/javascript" src="js/jquery.mobile-1.0rc2.min.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad(){
document.addEventListener("deviceready", onDeviceReady, true);
var db = window.openDatabase("Dummy_DB", "3.0", "Just a Dummy DB",200000);
alert("db="+db); //not printing
}
function onDeviceReady(){
navigator.notification.alert("doo");//only printing this
}
联系方式
函数onLoad(){
文件。添加的监听器(“deviceready”,onDeviceReady,true);
var db=window.openDatabase(“虚拟数据库”,“3.0”,“只是一个虚拟数据库”,200000);
警报(“db=“+db);//不打印
}
函数ondevicerady(){
navigator.notification.alert(“doo”);//仅打印此
}
例如
数据库
可能存在两个问题:
- 调用
时,文档已加载,但phonegap 没有。问题是您调用了onBodyLoad方法openDatabase
c()
。看见不是phonegap教程中建议的onDeviceReady
- 请检查您是否添加了相应的javascript。好办法 检查是为deviceready添加eventListener。如果它 当javascript加载正常时
addEventListener
是在onLoad
正文之外完成的请参见文档I中的示例指给你看。数据库已创建是:请参见此处:'此方法将创建一个新的SQL Lite数据库并返回一个数据库对象。使用Database对象操作数据。“我已将现有数据库与html文件连接,但如果我将其上载到phonegap build,它将在运行时生成新数据库(我认为是这样的)。您能告诉我是否可以使用html文件添加我的数据库并将其上载到phonegap,以便它可以为链接到我的数据库的不同平台生成应用程序。
<body onload="c()">
<h1>n Example</h1>
<p>Database</p>
</body>