连接到SQLite数据库从针对Android的PhoneGap的html文件 [英] connecting to sqlite database from phonegap html file for android

查看:142
本文介绍了连接到SQLite数据库从针对Android的PhoneGap的html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的PhoneGap和SQLite开发使用Android,iOS跨平台的移动应用程序,blackberry.For参考我使用的 http://docs.phonegap.com/en/1.0.0/phonegap_storage_storage.md.html 。我的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 phonegap has not. The problem is that you call the method c() onBodyLoad not onDeviceReady as advised in the phonegap tutorial. See here.
  • Please also check you add the javascript accordingly. A very good way to check is to add the eventListener for deviceready. If it gets fired the javascript is loaded ok.

这篇关于连接到SQLite数据库从针对Android的PhoneGap的html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆