Comment je peux exporter la base de données SQLite au stockage externe `je suis en train cette méthode mais montrant exceptionComment je peux exporter ma base de données SqlLite SDCard
public void exportdb() {
Log.e("data ","export");
File sd=Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
FileChannel source=null;
FileChannel destination=null;
String currentDBPath = "/data/"+ "com.example.kishababy.myapplication.DataBase" +"/databases/"+ "contactsManager";
String backupDBPath = "contactsManager";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
try {
source = new FileInputStream(currentDB).getChannel();
destination = new FileOutputStream(backupDB).getChannel();
destination.transferFrom(source, 0, source.size());
source.close();
destination.close();
Log.e("Toast","befor");
Toast.makeText(getApplicationContext(), "DB Exported!", Toast.LENGTH_LONG).show();
} catch(IOException e) {
e.printStackTrace();
Log.e("Exception",e.toString());
}
}
Exception lors teasting enter image description here
J'ai alredy ajouté cette autorisation –