Karlom Karlom - 5 months ago 12x
Linux Question

Where does android studio save sqlite db on Linux dev machine?

I'd like to insert data directly into the sqlite database of my app but I cannot find it anywhere on android studio path, even on my root path:

$sudo find / -type f -name 'myapp.db'

I know several similar questions have been asked before but the answers for Windows did not help me on Ubuntu Linux. So appreciate your help.


You app's db is only on the device. You can pull it from any connected device – this script pulls it from the first device.

Replace $package with your app's package name, and replace $db with the name of you app's db.

$ LC_ALL=C adb exec-out run-as $package cat databases/$db >db.sqlite

LC_ALL=C is to avoid some strange locale behavior on some systems.

adb is by default installed by Android Studio to ~/Android/Sdk/platform-tools/adb.


The program 'adb' is currently not installed. To run 'adb' please ask your administrator to install the package 'android-tools-adb'

This is Ubuntu telling you that you can install it from the Ubuntu package manager.

Normally you would already have it as a part of Android Studio.

Update 2

I don't have a script yet for pushing it back since push and run-as don't work together. You would have to do something like this (untested).

$ adb push db.sqlite /sdcard/temp.sqlite
$ cat <<EOF | adb shell
run-as $package
cat /sdcard/temp.sqlite >databases/$db