我通过这种方法将我的数据库(sqllite)复制到 sd 卡:
String currentDBPath =
"\\data\\com.powergroupbd.tripmileage\\databases\\tripmileagedatabase";
String backupDBPath = "tripmileagedatabase";
File currentDB = new File(data, currentDBpath);
File backupDB = new File(sd, 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();
这在模拟器中运行良好,但是当我将它安装在真实设备中时,这不会显示 sd 卡中的任何文件。我错过了什么?