从android的phonegap html文件连接到sqlite数据库
我正在使用phonegap和sqlite为android、ios、blackberry开发跨平台移动应用程序。作为参考,我正在使用http://docs.phonegap.com/en/1.0.0/phonegap_storage_storage.md.html。我的index.html低于
1.我在lib中得到了phonegap.jar
2.在assests/wwww中得到了phonegap.js
3.在我的硬盘中下载了sqlite浏览器和sql shell
4.得到了jquery.min.js
我想知道如何从index.html给出我的sqlite的位置,以便它可以与之建立连接。如果我只是传入phonegap.js,它就不会连接到sqlite。
<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
}
<body onload="c()">
<h1>n Example</h1>
<p>Database</p>
</body>
I am using phonegap and sqlite to develop cross-platform mobile app for android,ios,blackberry.For reference i am using http://docs.phonegap.com/en/1.0.0/phonegap_storage_storage.md.html. My index.html is below
1.i have got phonegap.jar in lib
2.got phonegap.js in assests/wwww
3.got sqlite browser and sql shell downloaded in my hardisk
4.got jquery.min.js
I would like to know how to give the location of my sqlite from index.html so that it can make a connection with it. If I just pass in phonegap.js it is not making connection to sqlite.
<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
}
<body onload="c()">
<h1>n Example</h1>
<p>Database</p>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几个可能的问题:
openDatabase
时,文档已加载,但 phonegap没有。问题是您调用了方法
c()
onBodyLoad
不是phonegap教程中建议的
onDeviceReady
。看此处。
要检查的是为 deviceready 添加事件监听器。如果得到
触发 javascript 加载正常。
There are couple of possible problems:
openDatabase
the document has loaded, but phonegaphas not. The problem is that you call the method
c()
onBodyLoad
not
onDeviceReady
as advised in the phonegap tutorial. Seehere.
to check is to add the eventListener for deviceready. If it gets
fired the javascript is loaded ok.