0

As I already export the database file from below code but I'm not able to open the exported file, how can I open the exported file?

 String dbName = Constants.DATABASE_NAME ; // Name without .db
 String currentDBPath = context.getDatabasePath(dbName).getPath();

 String backupDBPath = MyHelper.getDbExportPath() + "/" + dbName;
 File currentDB = new File(currentDBPath);
 File backupDB = new File(backupDBPath);
 if (currentDB.exists()) {
         FileChannel src = new FileInputStream(currentDB).getChannel();
         FileChannel dst = new FileOutputStream(backupDB).getChannel();
         dst.transferFrom(src, 0, src.size());
         src.close();
         dst.close();
}
  • Does this answer your question? [View contents of database created with Room Persistence Library](https://stackoverflow.com/questions/44429372/view-contents-of-database-created-with-room-persistence-library) – Nongthonbam Tonthoi Apr 29 '20 at 17:05

2 Answers2

0

For currentDBPath don't consider .db extention but for backupDBPath it require a .db extension

String backupDBPath = MyHelper.getDbExportPath() + "/" + dbName + ".db";

solve the problem

0

Download & Install DB Browser for SQLite

In Android Studio versions >= 3.0:

Open Device File Explorer via:

View > Tool Windows > Device File Explorer

In "Device File Explorer" Go to:

data > data > PACKAGE_NAME > databases

where PACKAGE_NAME is the name of your package

Mehul Boghra
  • 202
  • 3
  • 11