使用PhoneGap(主要目标Android)预填充客户端数据库 [英] Pre populate client database with PhoneGap (primary target Android)

查看:97
本文介绍了使用PhoneGap(主要目标Android)预填充客户端数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何执行此操作的文章和问题很少,但它们似乎都对iOS有偏见.

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

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

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

我需要一个数据库来运行该应用程序,因为该数据库包含很多信息,价值大约1mb(可以显示为.db/.sql).因此,我希望能够制作我的PhoneGap应用并为尽可能多的平台构建它.但是我想要它,以便用户一旦安装了应用程序,它将自动为他们安装数据库.

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.

某些解决方案似乎建议您在首次启动时创建数据库,但这似乎有点hack-ish,并且回避了问题.

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.

如果Android,iOS和其他提供商支持它,我很乐意切换到使用webSQL,但是由于PhoneGap封装了所有可用的本机OS DB功能,因此似乎可以使应用程序预先填充Android似乎更现实数据库并通过PhoneGap访问它,而不是预先填充Web数据库并通过webSql访问它.

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.

推荐答案

我刚刚回答了有关此主题的另一个类似问题. First PhoneGap没有实现已记录的存储功能.实际上,我们利用了所有基于Webkit的浏览器中实现的sqlite和localStorage功能.

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.

我的建议是预填充SQLite数据库,并在应用程序启动时将数据库复制到正确的位置,以便您的应用程序可以访问它.关于此主题的博客文章很不错:

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:

查看全文

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