public void exportDatabse(String databaseName) {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//"+getPackageName()+"//databases//"+databaseName+"";
String backupDBPath ="//database.sql";
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();
Log.i(TAG,"coping database sucessfull");
}
}
} catch (Exception e) {
Log.i(TAG,"exception! "+ e.getMessage());
}
}
调试sd
文件位置File sd = Environment.getExternalStorageDirectory();
时
/存储/模拟/ 0
复制的文件在我的SD卡中不可见。此外,我知道sd
文件的位置不正确。我怎样才能获得database.sql文件?
更新