问题描述
我目前正在开发一个使用SQLite数据库的Android应用程序.我正在寻找有关如何在Dropbox等外部服务之间进行数据库备份/还原的想法.我已经做了如下一些解释:
I am currently developing an Android application which makes use of the SQLite database. I am looking for ideas how to backup/restore the database to and from external services such as Dropbox. I have gone through some explanations such as below:
这些说明主要是关于本地备份的,但正如我提到的,我想备份到云,例如Dropbox.
These explanation are mainly about backing up locally, but I want to backup to cloud, as I mentioned, something like Dropbox.
请帮助...预先感谢...
Help please...Thanks in advance...
推荐答案
在此处使用答案,您可以获得一个.db File
对象形式对数据库的引用.
Using the answer here, you can get a reference to your database in the form of a .db File
object.
final String inFileName = "/data/data/<your.app.package>/databases/foo.db";
File dbFile = new File(inFileName);
一旦有了这个,就可以使用 Dropbox Sync API .
Once you have this, it's easy to read/write to a user's Dropbox using the Dropbox Sync API.
- 备份:使用 writeFromExistingFile()将此本地
File
写入Dropbox目录 - 还原:使用 getReadStream()来获得一个
FileInputStream
,该FileInputStream
可以写入.db文件所在的相应本地路径.
- Backup: Use writeFromExistingFile() to write this local
File
to the Dropbox directory - Restore: Use getReadStream() to get a
FileInputStream
that can write to the appropriate local path where your .db file goes.
这篇关于如何将Android上的SQLite数据库备份/还原到Dropbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!