I am trying to backup my database in my android app using sqlite. As this is the given code in google, but its not showing any result even error in logcat. What it is supposed to mean? Sorry im just new to android dev..
try {
File sd = Environment.getDataDirectory();
File data = Environment.getDataDirectory();
FileChannel source=null;
FileChannel destination=null;
if (sd.canWrite()) {
String currentDBPath = "//data//" + "com.example.jes.myapplication"
+ "//databases//" + "TINDERO.DB";
String backupDBPath = "//data//" + "com.example.jes.myapplication"
+ "//databases//" + "//TINDERO_BACKUP//" + "TINDERO.DB";
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();
Toast.makeText(getApplicationContext(), "Backup Successful!",
Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "Failed",Toast.LENGTH_SHORT).show();
}
}
});
Aucun commentaire:
Enregistrer un commentaire