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

问题描述

我正在使用Visual Studio 2013和Cordova工具包。

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

我的大部分应用程序都可以正常工作,现在我已准备好添加数据库逻辑。我有一个DB充满了引号,我需要绑定到应用程序。

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与数据库通信() )但是,我不知道如何使用预填充的DB。它总是创建一个新的空DB。我发现几个文章在网上一直说把数据库放在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.

有没有人能够使这项工作?

Has anyone been able to make this work?

推荐答案

老问题,但我会回答作为参考:我通过更改插件解决了这个问题。以前,我使用插件 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 ()。这个工作方式像一个魅力,它会将万维网文件夹中的数据库复制到设备。只要按照说明操作,不要忘记 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 dtabase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:31