因为我已经从下面的代码中导出了数据库文件,但是我无法打开导出的文件,我如何打开导出的文件?
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();
}发布于 2020-04-30 01:30:46
对于currentDBPath,不考虑.db扩展,但对于backupDBPath,它需要.db扩展
String backupDBPath = MyHelper.getDbExportPath() + "/" + dbName + ".db";解决问题
https://stackoverflow.com/questions/61507221
复制相似问题