Skip to content

Instantly share code, notes, and snippets.

@wuyexiong
Forked from anonymous/AppFilePuller
Created July 21, 2014 09:20
Show Gist options
  • Save wuyexiong/1b66179f6a1fd2244220 to your computer and use it in GitHub Desktop.
Save wuyexiong/1b66179f6a1fd2244220 to your computer and use it in GitHub Desktop.
#!/bin/bash
## Waking up ADB just in case
adb devices
## Desired files **REPLACE THESE WITH VALID FILEPATHS FOR YOUR APP**
FILEPATH_01="/data/data/com.example.app/databases/example.db"
FILEPATH_02="/data/data/com.example.app/shared_prefs/com.example.app_preferences.xml"
## Download function
download_files(){
files=( $FILEPATH_01 $FILEPATH_02 )
#remove previous working directory
rm -rf ./$1
#create a working directory based on device id from adb devices output
mkdir $1
#move into working directory before pulling files
cd ./$1
#update files to make them globally readable then pull them
for i in "${files[@]}"
do
#chmod files from device **UPDATE WITH THE PACKAGE NAME FOR YOUR APP**
adb -s $1 shell "run-as com.example.app chmod 666 $i"
#pull files from device
adb -s $1 pull -p $i
done
#back out to original calling directory
cd ..
}
## Run Download function across all connected devices
#get devices
adb devices | grep device | grep -v attached | cut -f 1 > actiontmpfile
while read deviceId;
do
#download files from device
download_files $deviceId
done < actiontmpfile
rm actiontmpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment