Search code examples
androidandroid-studioadbandroid-roomandroid-database

How to export a database from android app? Empty database result using ADB run-as


I need to populate a file .db programmatically so then I can put this in my asset folder of another project. So I'm trying to put a lot of data with Room in an empty database and then get the filled .db from the device using ADB shell.

I'm trying to save on my pc the .db file with this command on the ADB shell

adb exec-out run-as com.group.project cat databases/file.db > file.db

But the new file that I saved has no data and I'm sure it contains some records because I tried to query the database


Solution

  • Use Database Inspector.

    The latest version of Android Studio (Arctic Fox) can export database: https://youtu.be/-8tSZr7iMcw?t=288