且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将Android上的SQLite数据库备份/还原到Dropbox

更新时间:2023-02-02 15:43:24

此处使用答案,您可以获得一个.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.

  • 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.