问题描述
我使用的PhoneGap和SQLite开发使用Android,iOS跨平台的移动应用程序,blackberry.For参考我使用的。我的index.html低于
在lib目录1.我已经得到phonegap.jar
在入资产价值2.got phonegap.js / WWWW
3.got源码的浏览器和SQL壳牌在我hardisk下载
4.got jquery.min.js
我想知道如何从index.html的,以便它可以与它的连接给我的SQLite的位置。如果我只是通过它不是让连接sqlite的phonegap.js。
< HEAD>
<标题>联系例< /标题>
<脚本类型=文/ JavaScript的字符集=utf-8SRC =JS / PhoneGap的-1.4.0.js> < / SCRIPT>
<脚本类型=文/ JavaScript的SRC =JS / jquery.min.js/>< / SCRIPT>
<脚本类型=文/ JavaScript的SRC =JS / jquery.mobile-1.0rc2.min.js>< / SCRIPT>
<脚本类型=文/ JavaScript的字符集=utf-8>
功能的onLoad(){
document.addEventListener(deviceready,onDeviceReady,真正的);
变种DB = window.openDatabase(Dummy_DB,3.0,只是一个虚拟的DB,200000);
警报(DB =+ DB); //没有打印
}
功能onDeviceReady(){
navigator.notification.alert(斗); //打印仅此
}
<身体的onload =C()>
&所述; H1将N实施例&下; / H1>
&所述p为H.;数据库与所述; / P>
< /身体GT;
有几个可能出现的问题:
- 当你调用
的openDatabase
该文件已加载,但的PhoneGap 的
也没有。问题是,你调用方法C()
onBodyLoad
没有onDeviceReady
作为买卖本PhoneGap的教程。看到
。 - 另外,也请你添加相应的JavaScript。一个很好的方法
检查是添加事件监听的deviceready。如果它获得
燃煤的JavaScript加载ok了。
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>
There are couple of possible problems:
- When you call
openDatabase
the document has loaded, but phonegaphas not. The problem is that you call the methodc()
onBodyLoad
notonDeviceReady
as advised in the phonegap tutorial. Seehere. - Please also check you add the javascript accordingly. A very good wayto check is to add the eventListener for deviceready. If it getsfired the javascript is loaded ok.
这篇关于连接到SQLite数据库从针对Android的PhoneGap的html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!