在Cordova(适用于Android)和Visual Studio中打开预填充的SQLite数据库 [英] Open prepopulated SQLite database in Cordova (for android) and Visual Studio

查看:70
本文介绍了在Cordova(适用于Android)和Visual Studio中打开预填充的SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2013和Cordova Tools软件包。

I'm working with Visual Studio 2013 and the Cordova Tools package.

我的大部分应用程序都在工作,现在可以添加数据库了。逻辑。我有一个充满引号的数据库,我需要将其绑定到应用程序中。

I have most of my app working, and I'm now ready to add the DB logic. I have a DB full of quotes, and I need to tie that into the app.

跟随此链接:使用SQLite添加动态数据

我能够让SQLite与数据库对话(使用sqlitePlugin )但是,我不知道如何使用预填充的数据库。它总是创建一个新的空数据库。我在网上发现了几篇文章,这些文章一直在说将数据库放入www文件夹 ...但是Cordova项目没有www文件夹。

I was able to get SQLite to talk to a DB (using the sqlitePlugin) However, I can't figure out how to use a pre-populated DB. It always created a new empty DB. I've found several articles on the web that keep saying "put the db in the www folder"... but the Cordova project doesn't have a www folder.

将SQLite DB文件放入根目录不起作用,我尝试使用路径并将其放在子目录中。

Putting the SQLite DB file in the root doesn't work, and I tried using a path and putting it in a sub-dir. No luck there either.

有人能做这项工作吗?

推荐答案

旧问题,但我将作参考:我通过更改插件解决了此问题。以前,我使用的插件是 cordova-sqlite-storage https://github.com/litehelpers/Cordova-sqlite-storage ),但它不会复制预先填充的数据库。

Old question, but I will answer to serve as a reference: I solved this problem by changing the plugin. Previously, I was using plugin cordova-sqlite-storage (https://github.com/litehelpers/Cordova-sqlite-storage), but it doesn't copy the prepopulated database. It always creates an empty one.

经过几天的战斗,我卸载了插件并安装了一个: cordova-plugin-sqlite https://www.npmjs.com/package/cordova-plugin- sqlite )。这就像一个超级按钮一样,它将www文件夹中的数据库复制到该设备。只需按照说明进行操作,不要忘记 createFromLocation 参数。

After days of fighting, I uninstalled the plugin and installed this one: cordova-plugin-sqlite (https://www.npmjs.com/package/cordova-plugin-sqlite). This one works like a charm, it will copy the DB in the www folder to the device. Just follow the instructions and don't forget the createFromLocation parameter.

两个插件都来自这个奇怪的地方同一位作者,而且似乎都是活跃的项目。走吧。

The strange bit it that both plugins are from the same author, and both seem to be active projects. Go figure.

这篇关于在Cordova(适用于Android)和Visual Studio中打开预填充的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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