Skip to content

Instantly share code, notes, and snippets.

@nrudenko
Last active December 28, 2015 05:18
Show Gist options
  • Save nrudenko/7448447 to your computer and use it in GitHub Desktop.
Save nrudenko/7448447 to your computer and use it in GitHub Desktop.
Script for getting database form device via adb and open in sqlite_client(work with not rooted devices)
#!/bin/sh
# Script for getting database form device via adb and open in sqlite_client(work with not rooted devices)
#
# While you aren't breaking script execution(CTLR+C),
# each closing of sqlite_client will be download and open database again and again.
#
# Note: if you don't have installed sqliteman override sqlite_client variable with your favorite client
#
# Usage: open_db.sh {app_package} {db_name}
# Example: open_db.sh com.example.app example_app.db
sqlite_client=sqliteman
adb_path=$ANDROID_HOME/platform-tools/adb
app_package=$1
db_name=$2
dest_path=/tmp/$db_name
ext_storage=$($adb_path shell echo -n \$EXTERNAL_STORAGE)
device_dest_path=$ext_storage/$db_name.db
while true
do
rm -rf $dest_path
#$adb_path shell "run-as $app_package cat databases/$db_name >> $device_dest_path"
#$adb_path pull $device_dest_path $dest_path
$adb_path pull /data/data/$app_package/databases/$db_name $dest_path
#$adb_path shell "rm -rf $device_dest_path"
$sqlite_client $dest_path
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment