PhoneGap 使用什么数据库,大小限制是多少? [英] What database does PhoneGap use and what is the size limit?

查看:22
本文介绍了PhoneGap 使用什么数据库,大小限制是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个 HTML5 数据库,它抽象了 localStorage、indexedDB 和 WebSQL.直接使用 HTML5,我的数据库选项如下所示:

  • IE10 - indexedDB - 最大 1GB
  • FireFox - indexedDB - 无限制
  • Safari - WebSQL - 最大 50MB
  • Chrome - IndexedDB(或 Web SQL)- 无限制(使用 HTML5 配额 API ref1ref2)
  • Opera - WebSQL(直到他们切换到 webkit?) - 无限制

我想使用 PhoneGap 或 Quota API 扩展最大数据库大小.从 PhoneGap 的文档看来,当前的 PhoneGap 数据库生态圈是:

  • WebSQL - Android、Blackberry、iPhone 和 webOS
  • localStorage - Windows Phone 7
  • indexedDB - Windows Phone 8 和,我我猜,到处都有 indexedDB 可用,但 WebSQL 不可用.

还有 PhoneGap SqlLite 插件.iOSAndroid, Windows Phone 8+

<小时>

问题 1 - 我对 PhoneGap 将使用的数据库的理解准确吗?

问题 2 - 是否有关于给定类型的 PhoneGap 数据库将存储多少数据的可靠文档?*如果是PhoneGap数据库而不是浏览器数据库实现.

问题 3 - PhoneGap 是否计划遵守 Web存储标准从而放弃了 WebSQL 以支持 indexedDB?如果是这样,一旦切换到 indexedDB,我是否仍然能够使用我现有的 WebSQL 代码(通过内置的 PhoneGap-polyfill)?

问题 4 - 在数据库大小有限且无法通过 PhoneGap 或 Quota API 扩展但可以访问文件系统的情况下,假设额外"是否合理?数据可以存储在设备的文件系统或 SD 卡上?

解决方案

我对 PhoneGap 将使用的数据库的理解准确吗?

是的.PhoneGap 可以使用 LocalStorage、SessionStorage 或 SQLite 数据库.您也可以使用 PhoneGap 通过插件连接到设备本机类,并传递本机类数据,然后将其存储在设备上.

<块引用>

是否有关于给定类型的 PhoneGap 数据库将存储多少数据的可靠文档?如果是 PhoneGap 数据库而不是浏览器数据库实现.

  1. 本地存储 :: 10MB
  2. 会话存储:: 10MB
  3. SQLite 数据库 :: 50MB-80MB(取决于设备)
  4. 使用插件调用的原生数据库::无限数据量
  5. IndexedDB :: 5MB.仍然存在.但是非常有问题,这里有运行它的设备/操作系统列表

<块引用>

PhoneGap 是否计划遵守 Web 存储标准,从而放弃 WebSQL 以支持 indexedDB?如果是这样,一旦切换到 indexedDB,我是否仍然能够使用我现有的 WebSQL 代码(通过内置的 PhoneGap-polyfill)?

WebSQL 正在慢慢被弃用.它的替代品是 IndexedDB 或 SQLite.但是,对您来说最好的选择是 SQLite 或本机数据库(例如 iOS 上的 Core Data)

<块引用>

在数据库大小有限且无法通过 PhoneGap 或 Quota API 扩展但可以访问文件系统的情况下,假设额外"数据可以存储在设备的文件系统或在 SD 卡上?

绝对有可能.

  • 在 Android 上,您可以指定数据库的位置,从而将数据推送到外部数据库.
  • 在 iOS 上,您可以使用本机数据库调用将数据存储在 CoreData 上,没有外部存储器.
  • 在所有操作系统的所有情况下,您都可以创建一个平面数据库文件,如文本文件,将您的数据存储在键值列表中,然后在首次运行时将它们拉入您的应用程序.在这种情况下要注意内存管理.

我在 中添加了关于如何为 SQLite 和 LocalStorage 数据库进行编码的说明我的回答.

I wrote an HTML5 database that abstracts localStorage, indexedDB, and WebSQL. Using straight HTML5 my database options look like this:

  • IE10 - indexedDB - 1GB max
  • FireFox - indexedDB - unlimited
  • Safari - WebSQL - 50MB max
  • Chrome - IndexedDB (or Web SQL) - unlimited (with the HTML5 Quota API ref1, ref2)
  • Opera - WebSQL (until they switch to webkit?) - unlimited

I would like to expand the maximum database size using PhoneGap or the Quota API. From PhoneGap's documentation it looks like the current PhoneGap database ecosphere is:

  • WebSQL - Android, Blackberry, iPhone, and webOS
  • localStorage - Windows Phone 7
  • indexedDB - Windows Phone 8 and, i am guessing, everywhere indexedDB is available but WebSQL isn't.

There are also the PhoneGap SqlLite plugins. iOS, Android, Windows Phone 8+


QUESTION 1 - Is my understanding of what database PhoneGap will use accurate?

QUESTION 2 - Is there any solid documentation about how much data a PhoneGap database of a given type will store? *If it is a PhoneGap database and not the browsers database implementation.

QUESTION 3 - Does PhoneGap have plans to adhere to the the Web Storage standards thereby dropping WebSQL in favor of indexedDB? If so, will I still be able to use my existing WebSQL code (via a built in PhoneGap-polyfill) once the switch to indexedDB is made?

QUESTION 4 - In situations where database size is limited and cannot be expanded by either PhoneGap or the Quota API, but access to the file system is available, is it reasonable to assume that "extra" data could be stored on the device's file system or on a SD card?

解决方案

Is my understanding of what database PhoneGap will use accurate?

Yes it is. PhoneGap can use LocalStorage, SessionStorage, or SQLite databases. You can also, alternatively use PhoneGap to connect to the devices native classes via a plugin, and pass the native class data, that it will then store on the device.

Is there any solid documentation about how much data a PhoneGap database of a given type will store? If it is a PhoneGap database and not the browsers database implementation.

  1. LocalStorage :: 10MB
  2. SessionStorage :: 10MB
  3. SQLite Database :: 50MB-80MB (depends on the device)
  4. Native Database using plugin call :: Unlimited data amount
  5. IndexedDB :: 5MB. Still existant. But very buggy, theres a list of devices/OS's that run it here

Does PhoneGap have plans to adhere to the the Web Storage standards thereby dropping WebSQL in favor of indexedDB? If so, will I still be able to use my existing WebSQL code (via a built in PhoneGap-polyfill) once the switch to indexedDB is made?

WebSQL is slowly being deprecated. Its replacement is IndexedDB or SQLite. The best option for you, however, is either SQLite or the Native Database (for example Core Data on the iOS)

In situations where database size is limited and cannot be expanded by either PhoneGap or the Quota API, but access to the file system is available, is it reasonable to assume that "extra" data could be stored on the device's file system or on a SD card?

It is definitely possible.

  • On Android you can specify the location of the database, and therefore push data to an external database.
  • On iOS, you can use the native database call to store data on CoreData, there is no external memory.
  • In all cases of all OS's, you can create a flat database file, like a Text file, store your data in key-value lists, and then pull those into your app at first run. Beware of the memory management in this case.

I've added an explanation of how to go about coding for the SQLite and LocalStorage databases in my answer.

这篇关于PhoneGap 使用什么数据库,大小限制是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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