PhoneGap 上的 SQLite 数据库 [英] SQLite database on PhoneGap

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

问题描述

我想使用 PhoneGap 为 iPhone 实现 SQLite 数据库.我知道 iPhone 本机应用程序中的一些基础 SQLite 数据库.但是如何在PhoneGap中实现SQLite数据库呢?

I want to implement SQLite database for iPhone using PhoneGap. I know some basics SQLite database in iPhone native application. But how can I implement SQLite database in PhoneGap?

推荐答案

请务必记住,PhoneGap 是打包在浏览器组件中的网络应用.适用于移动 WebKit 的所有内容也将适用于 PhoneGap,PhoneGap 中的环境也与在桌面浏览器中打开 HTML 文件非常相似.

It's important to remember that PhoneGap is web apps packaged in a browser component. Everything that applies to mobile WebKit will apply to PhoneGap as well, and the environment in PhoneGap is also very similar to opening an HTML-file in a desktop browser.

您需要所谓的Web SQL 数据库".

You want what's called a 'Web SQL Database'.

http://www.w3.org/TR/webdatabase/

自撰写此答案以来,此规范已被标记为已弃用,现在依赖它已成为官方的 Bad Idea™.

This specification has been marked as deprecated since the writing of this answer and it's now an officially Bad Idea™ to depend on it.

实际上,它在大多数支持它的浏览器中都基于 SQLite,但它不会完全是 SQLite 实现.但它很接近.在 Chrome 或 Safari 中,您可以使用开发者工具查看其内容,查看资源"选项卡 -> 数据库(您想在使用 PhoneGap 之前在桌面浏览器上测试基本功能).

In reality, it's based on SQLite in most browsers that support it, but it won't be exactly the SQLite implementation. But it's close. In Chrome or Safari, you can go have a look at it's contents with your developer tools, look at the 'Resources' tab -> Databases (you want to test out basic functionality on a desktop browser before trying in PhoneGap).

它在 PhoneGap 中的工作方式与在桌面浏览器中完全相同.

It will work exactly the same in PhoneGap as in desktop browsers.

Web SQL 数据库是更广泛地称为本地存储"的一种实现.我认为关于该主题的最佳介绍文本可以在 Mark Pilgrim 的Dive into HTML5"中找到:

Web SQL databases are one implementations of what's more broadly referred to as "local storage". I think that the best introductionary text on that topic can be found in Mark Pilgrim's "Dive into HTML5":

http://diveintohtml5.info/storage.html

对于 PhoneGap 和桌面浏览器仍然一样有效.

Still just as valid for PhoneGap as for desktop browsers.

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

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