【发布时间】:2020-08-13 20:40:35
【问题描述】:
由于我已经从下面的代码中导出了数据库文件,但我无法打开导出的文件,我该如何打开导出的文件?
String dbName = Constants.DATABASE_NAME ; // Name without .db
String currentDBPath = context.getDatabasePath(dbName).getPath();
String backupDBPath = MyHelper.getDbExportPath() + "/" + dbName;
File currentDB = new File(currentDBPath);
File backupDB = new File(backupDBPath);
if (currentDB.exists()) {
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
【问题讨论】:
标签: android android-room