替换/覆盖本地SQLite数据库文件 [英] Replace/overwrite local SQLite database file

查看:755
本文介绍了替换/覆盖本地SQLite数据库文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主项目文件夹中有一个本地预先填充的SQLite数据库文件,我从中获取了应用程序中所需的数据。我使用以下方法建立连接:

I' ve got a local pre-populated SQLite database file in my main project folder from which I get the needed data in my application. I establish a connection using:

SQLiteAsyncConnection conn = new SQLiteAsyncConnection("mydb.sqlite");

这个文件以某种方式更新(不是本地的,不是由我或用户),因此,在我的应用程序中检查新版本后,我必须用我为此目的下载的新文件覆盖我的.sqlite文件。

This file gets somehow updated (not locally & not by me or the user) so, after checking for new versions in my application, I have to overwrite my .sqlite file with the new one I download for that purpose.

这可能吗?如果有,你有什么建议吗?

Is that possible? If so, have you got any suggestions?

推荐答案

klitemnistros

您可以替换dataBase。

You can replace you dataBase.

如果您需要对DB的读/写访问,您必须将DB复制到IsoStorage以便工作机会;只读 - 可以从包读取。

If you need read/write acces to DB, you must copy DB to IsoStorage for opportunity to work; only read - can read from package.

例如,您将第一个数据库复制到IsoStorage并下载新数据库。您可以删除旧的并使用相同的名称添加新的isoStorage。当您下次运行该应用程序时 - 您将与新数据库建立连接。 

For example, you copy your first DB to IsoStorage and after you download new DB. You can delete old and add new to isoStorage with the same name. And when you will run the application the next time - you will gave connection with new DB. 

当应用程序运行时,您可以保存具有临时名称的新数据库以及应用程序何时关闭 - 替换旧的和新的。

When app running you can save new DB with temp name and when app will closing - replace old with new.

抱歉英语不好。

问候,尼基塔。


这篇关于替换/覆盖本地SQLite数据库文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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