使用 PhoneGap 预填充客户端数据库(主要目标 Android)

发布于 2024-12-28 19:14:29 字数 650 浏览 1 评论 0原文

有一些关于如何做到这一点的文章和问题,但它们似乎都偏向 iOS。

首先,我目前正在使用 PhoneGaps 数据库功能: http://docs.phonegap.com/en/1.0.0/phonegap_storage_storage .md.html

我有一个运行应用程序所需的数据库,因为它包含大量信息,大约有 1mb 的大小(可以公开为.db/.sql)。因此,我希望能够制作我的 PhoneGap 应用程序并为尽可能多的平台构建它。但是我希望用户一旦安装了应用程序,它就会自动为他们安装数据库。

一些解决方案似乎建议在首次启动时创建数据库,但这似乎有点黑客行为并回避了问题。

如果 Android、iOS 和其他提供商支持 webSQL,我非常乐意改用 webSQL,但是,由于 PhoneGap 封装了任何可用的本机 OS DB 功能,因此您可以让应用程序来预填充 Android 数据库并访问它,这似乎更加现实它通过 PhoneGap 进行,而不是预先填充 Web 数据库并通过 webSql 访问它。

希望这个问题有意义,并且自去年年中以来已经取得了进展,这似乎是关于此类事情的最后一篇最新文章。

There have been a few articles and questions about how to do this but they all seem to have a bias to iOS.

So first of all I am currently using PhoneGaps database functionality:
http://docs.phonegap.com/en/1.0.0/phonegap_storage_storage.md.html

I have a database I need for the app to run from as it contains a lot of information, probably about 1mb worth (can be exposed as .db/.sql). So I want to be able to make my PhoneGap app and build it for as many platforms as possible. However I want it so that as soon as the user has installed the app it automatically installs the database for them.

Some of the solutions seem to recommend creating the database on first boot, but this just seems a bit hack-ish and sidestepping the problem.

I am more than happy to switch over to use webSQL if Android, iOS and other providers support it, however as PhoneGap wraps any available native OS DB functionality it seemed more realistic that you can get an app to pre-populate an Android database and access it via PhoneGap than pre-populate a web database and access it via webSql.

Hopefully this question makes sense and there have been advances since mid last year, which seems to be the last up to date post on this sort of thing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

违心° 2025-01-04 19:14:29

我刚刚回答了关于这个主题的另一个类似问题。第一个 PhoneGap 没有实现记录的存储功能。事实上,我们利用了所有基于 webkit 的浏览器中实现的 sqlite 和 localStorage 功能。

我的建议是预先填充 SQLite 数据库,并在应用程序启动时将数据库复制到正确的位置,以便您的应用程序可以访问它。关于这个主题有一篇很好的博客文章:

http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html?utm_source=feedburner&utm_medi um=feed&utm_campaign=Feed%3A+GauravSTomarBootstrappingIntelligence+%28Gaurav+S+Tomar+%3A+Bootstrapping+Intelligence%29

I just answered another similar question on this topic. First PhoneGap doesn't implement the Storage function that is documented. In fact we take advantage of the sqlite and localStorage functionality that is implemented in all webkit based browsers.

My recommendation is for you to pre-populate a SQLite DB and on application startup copy the DB to the correct location so your app can access it. There is a good blog post on this topic at:

http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+GauravSTomarBootstrappingIntelligence+%28Gaurav+S+Tomar+%3A+Bootstrapping+Intelligence%29

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文