I am exporting my sqllite database using this code.
public void exportDB() {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
FileChannel source = null;
FileChannel destination = null;
String backupDBPath = "contactsManager.db";
String currentDBPath = "/data/" + "com.packagename"
+ "/databases/" + backupDBPath;
System.out.println("oooooooooooooo" + currentDBPath);
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();
Toast.makeText(getApplicationContext(), "DB Exported!", Toast.LENGTH_LONG)
.show();
System.out.println("---------db exporeted");
} catch (Exception e) {
e.printStackTrace();
}
}
But I am getting a file not found exception.This is the log.
java.io.FileNotFoundException: /data/data/packagename/databases/contactsManager.db: open failed: ENOENT (No such file or directory)
Aucun commentaire:
Enregistrer un commentaire