如何引用 Xamarin.Android 中已存在的 SQLite 数据库? [英] How to reference SQLite database that already exists in Xamarin.Android?

查看:48
本文介绍了如何引用 Xamarin.Android 中已存在的 SQLite 数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了 SQLite 数据库并将其复制到项目的根目录中:

I have created SQLite database and have copied it in the root of the project like that:

数据库名为 MobileSell.db 它在 Visual Studio 中是这样显示的:

The database is called MobileSell.db It appears in Visual Studio like that:

我的问题是如何引用它,以便之后我可以说 connection.InsertIntoTableArticles(value)(这是伪代码)

My question is how can I reference it so afterwards I can say connection.InsertIntoTableArticles(value)(this is pseudo code)

推荐答案

可以参考

只需三个步骤即可实现:

There only three steps to achieve it:

1) 在项目中创建与Resources 文件夹平行的Assets 文件夹,将.db 文件放入其中.

1) Create Assets folder which is parallel with Resources folder in your project, put your .db file into it.

2) 首次打开应用程序时将.db文件复制到SDCard;

2) Copy the .db file to SDCard when first open the app;

3) 使用 SQLite.SQLiteConnection(path) 打开你的 .db 并查询它.

3) Use SQLite.SQLiteConnection(path) to open your .db and query it.

这篇关于如何引用 Xamarin.Android 中已存在的 SQLite 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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