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());
}
}
While debugging the sd
file location File sd = Environment.getExternalStorageDirectory();
is
/storage/emulated/0
The copied file isn't visible in my SDcard. Moreover, I know the location of the sd
file is incorrect. How can I get the database.sql file?
UPDATE