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'
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.
$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
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.
I don't have a script yet for pushing it back since
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 exit exit EOF