如何在PhoneGap的(Apache的科尔多瓦)API的变化 [英] How to make changes in phoneGap ( Apache Cordova ) Api

查看:121
本文介绍了如何在PhoneGap的(Apache的科尔多瓦)API的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PhoneGap的SD卡访问现有的.db文件,但下面给出的方法的PhoneGap只接受数据库名称而不是路径。
变种DB = window.openDatabase(数据库,1.0,科尔多瓦演示,600000);

所以我想做出科尔多瓦-1.7.0.jar具有本地code与设备进行通信的变化。我发现Storage.java拥有的openDatabase(字符串分贝,版本字符串,字符串DISPLAY_NAME,长尺寸)的方法,其中我只需要指定一个变量即
PATH =到/ mnt / SD卡/数据库,并重新编译.jar文件。所以我下载科尔多瓦源从下面给出的路径即 https://github.com/apache/incubator-cordova -Android 并取得了这个变化,创造了新的.jar文件在我的项目中使用。但它给错误时加载应用程序。


解决方案

这将是更好地写你的code作为一个插件为PhoneGap的使用WebKit数据库。已经有用于访问外部SQLite数据库的插件,但它是针对iOS。不过,这将是一个很好的起点为你写你自己的Andr​​oid插件。现有的插件可以在 https://github.com/davibe/Phonegap-SQLitePlugin <找到/ p>

I wanted to access my existing .db file from sdcard using phoneGap but method available in phoneGap accepts only database name not path as given below. var db = window.openDatabase("Database", "1.0", "Cordova Demo", 600000);

so I thought to make changes in cordova-1.7.0.jar which has native code to communicate with device. I found Storage.java which has openDatabase(String db, String version, String display_name,long size) method wherein I just need to assign a variable i.e path = "/mnt/sdcard/database" and recompile the .jar file. so I downloaded cordova source from below given path i.e. https://github.com/apache/incubator-cordova-android and made changes in this and created new .jar file to use in my project. but its giving error when application loads.

解决方案

It would be better to write your code as a plugin as PhoneGap uses the WebKit database. There is already a plugin for accessing external SQLite database, but it is for iOS. Nevertheless, it would be a good starting point for you to write your own plugin for Android. The existing plugin can be found in https://github.com/davibe/Phonegap-SQLitePlugin

这篇关于如何在PhoneGap的(Apache的科尔多瓦)API的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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