如何使用电话间隙访问数据库
我是 Android PhoneGap 的新手。我正在使用本机应用程序存储和检索数据。我不知道如何将检索到的数据从本机显示到phonegap(HTML)页面。
谁能指导我如何使用phonegap访问sqlite?
提前致谢。
I am new to android phonegap. i am storing and retrieving data using native application. i dont know how to display the retrieved data from native to phonegap(HTML)page.
can anyone pls guide me how to access sqlite with phonegap.?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要首先为 Phonegap 创建一个 Android 插件,通过它您将能够访问本机代码,从而访问本机数据库,如下所示
然后创建一个 sqlite.js 文件,如下所示
将此 sqlite.js 导入您的页面(index.html )然后最后使用这样的插件
让我知道这是否适合您
You need to first create a Android plugin for Phonegap through which you will be able to access the native code and hence the native DB like this
After that Create a sqlite.js file like this
Import this sqlite.js in your page(index.html) and then finally use the plugin like this
Let me know if this worked out for you
编写一个phonegap插件将数据从native端传递到html(js)
http://wiki.phonegap.com/w/page/36753494/How%20to%20Create%20a%20PhoneGap%20Plugin%20for%20Android
Write an phonegap plugin to pass the data from native side to html (js)
http://wiki.phonegap.com/w/page/36753494/How%20to%20Create%20a%20PhoneGap%20Plugin%20for%20Android
好吧,您可能应该使用 HTML5 函数来存储和检索 sqlite 数据库中的数据。但是,如果您打算使用本机代码执行此操作,则应该查看我们的实现,该实现用于不支持 sqlite 的旧版 Android 设备。
https://github.com/cordova/cordova -android/blob/master/framework/assets/js/storage.js
https://github.com/cordova /cordova-android/blob/master/framework/src/com/phonegap/Storage.java
Well, you probably should use the HTML5 functions to store and retrieve data from a sqlite DB. However, if you are set on doing it with native code you should look at our implementation which was used for older Android devices that don't support sqlite.
https://github.com/cordova/cordova-android/blob/master/framework/assets/js/storage.js
https://github.com/cordova/cordova-android/blob/master/framework/src/com/phonegap/Storage.java