title: Android import database from external storage
body: <p>I'm trying to import the database file from an external drive (USB), to restore the backup data. The file exists and the path is right, but the database is not imported, this is my code:</p>
  
  <pre><code>File usb = new File("/storage/UsbDriveA/BackupHM/database.db");
  File currentDB = getDatabasePath("database.db");
  
  FileChannel source = null;
  FileChannel destination = null;
  String backupDBPath = "/storage/UsbDriveA/BackupHM/database.db";
  File backupDB = new File(usb, backupDBPath);
                          try {
                              source = new FileInputStream(backupDB).getChannel();
                              destination = new FileOutputStream(currentDB).getChannel();
                              destination.transferFrom(source, 0, source.size());
                              source.close();
                              destination.close();
                              Toast toast1 = Toast.makeText(getApplicationContext(), ("Restore ok"), Toast.LENGTH_SHORT);
                              toast1.show();
                              finish();
                          } catch (IOException e) {
                              e.printStackTrace();
                              Toast toast = Toast.makeText(getApplicationContext(), ("Error!"), Toast.LENGTH_LONG);
                              toast.show();
                          }
                      }
  </code></pre>