lundi 1 décembre 2014

Database not exporting to sd card


I'm almost new to Android development. I'm trying to backup my apps DB to SD card but failed. I tried below the codes but it not work. Event any error I did not get.



File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//"+ "app.myapp.test" +"//databases//"+"my_database";
String backupDBPath = "/Backup/database";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);

FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}


Any information will be appreciated.





Aucun commentaire:

Enregistrer un commentaire