So: there is a program that works with the database, and there is a need to transfer the database between devices. I implemented the export of the database, but how to import the database into the program?
Export code:
private void exportDB(){ File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); FileChannel source=null; FileChannel destination=null; String currentDBPath = "/data/"+ "your package name" +"/databases/"+SAMPLE_DB_NAME; String backupDBPath = SAMPLE_DB_NAME; 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(this, "DB Exported!", Toast.LENGTH_LONG).show(); } catch(IOException e) { e.printStackTrace(); } }