PhoneGap/iOS 上的 SQLite 数据库 - 可能超过 5mb [英] SQLite database on PhoneGap / iOS - More than 5mb possible

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

问题描述

我对在 iOS 上的 Phonegap-Native-App 中使用 SQLite 的局限性感到有些困惑.

I'm a little confused about the limitations of using SQLite in a Phonegap-Native-App on iOS.

您可以阅读许多关于 5mb 存储空间限制以及您的 Ipad 可以要求您增加存储空间这一事实的帖子.

You can read many posts about the limit of 5mb storage and the fact, that your Ipad can ask you to increase the storage.

现在我已经设法使用通常的 Phonegap-Storage-API 将近 7000 行插入到我的 SQLite 数据库中.相应的 db 文件大小为 26 MB.以下选择语句select * from"起作用并显示数据库的内容.我已经在模拟器和设备上做到了这一点.我没有收到增加存储空间的问题.

Now I've managed to insert nearly 7000 rows into my SQLite database, using the usual Phonegap-Storage-API. The corresponding db-file has a size of 26 MB. A following select-statement "select * from " worked and was showing the db's content. I've done that in the simulator and on the device. I didn't get the question to increase the storage.

怎么会这样?我误解了什么吗?Phonegap 中的 SQLite dbs 真的有 5mb 的限制吗?我使用的是 Phonegap 1.2 和 iOS 5.

How can that be? Do I misunderstand something? Is there really a 5mb limit for SQLite dbs in Phonegap? I'm using Phonegap 1.2 and iOS 5.

推荐答案

您可以使用带有 phonegap 插件的原生 SQLite DB(与 WebSQL 相同),并且不会受到任何限制.在iOS5.1中,WebSQL被认为是可以随时删除的临时数据...那个插件将数据库保存在Document文件夹中,这意味着该数据库不会被删除,而是由iCloud保存.

You can use a native SQLite DB (same as WebSQL) with a phonegap plugin, and you will not have any limitation. In iOS5.1, WebSQL is considered temporary data that can be deleted at any time...That plugin save the database in the Document folder, that mean that the DB is not deleted and is saved by iCloud.

这里是 Native SQLite phonegap 插件:https://github.com/davibe/Phonegap-SQLitePlugin关于这个插件,WebSQL API 之间有一些区别,这里是一个适配器:https://gist.github.com/2009518

Here is the Native SQLite phonegap plugin : https://github.com/davibe/Phonegap-SQLitePlugin Regarding this plugin, there are some differences between the WebSQL API, here is an adaptor: https://gist.github.com/2009518

您还应该将旧的 WebSQL db 文件(存储在 Library/WebKit 或 Caches 目录中)迁移到 Document 文件夹.这是一个代码来做到这一点:https://gist.github.com/2009491

You should also migrate the old WebSQL db file (stored in Library/WebKit or Caches directory) to the Document folder. Here is a code to do that : https://gist.github.com/2009491

如果数据很重要,您应该将其保存到服务器.我写了一个小库来将 SQlite 数据库同步到服务器:https://github.com/orbitaloop/WebSqlSync

And if the data are important, you should save it to a server. I wrote a small lib to synchronize the SQlite DB to a server : https://github.com/orbitaloop/WebSqlSync

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

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