Skip to content

Instantly share code, notes, and snippets.

@mtsahakis
Last active August 30, 2019 16:42
Show Gist options
  • Save mtsahakis/a85cc97c411f3fd9331939f37e751742 to your computer and use it in GitHub Desktop.
Save mtsahakis/a85cc97c411f3fd9331939f37e751742 to your computer and use it in GitHub Desktop.
This script takes three command line arguments, device id {as read from adb devices -l}, your application's package id {like com.mobile.myapp} and database name as exists inside data/data/{package id}/databases directory of the device or emulator. It then starts sqlitebrowser pointing to the database just pulled from the device.
#!/usr/bin/env bash
# check if a device is supplied as a command line argument
DEVICE_ID=$1
if [[ "$DEVICE_ID" == "" ]]; then
echo "No device id supplied"
exit 1
fi
# check if a package id is supplied as a command line argument
PACKAGE_ID=$2
if [[ "$PACKAGE_ID" == "" ]]; then
echo "No package id supplied"
exit 1
fi
# check if a database name is supplied as a command line argument
DATABASE=$3
if [[ "$DATABASE" == "" ]]; then
echo "No database name supplied"
exit 1
fi
# start sqlitebrowser by pulling data for the right device / package /database
TMP_DIR=$(mktemp -d --tmpdir $PACKAGE_ID.XXXXXXX)
adb -s $DEVICE_ID pull data/data/$PACKAGE_ID/databases/$DATABASE $TMP_DIR
pkill sqlitebrowser
nohup sqlitebrowser $TMP_DIR/$DATABASE &>/dev/null &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment