sqlite - Export database in android -


i exporting sqllite database using 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 getting file not found exception.this log.

java.io.filenotfoundexception: /data/data/packagename/databases/contactsmanager.db: open failed: enoent (no such file or directory)

the currentdb (source) not exist. check path.

also make sure destinationpath exists backupdb.mkdir()


Comments