Last active
January 15, 2021 13:27
-
-
Save letroll/5ba28378ea22c835936b15cbdd0665f8 to your computer and use it in GitHub Desktop.
[log sharedpreference] log current application shared preference #android #adb #log #preference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logPackageName() { | |
adb shell dumpsys activity recents | grep 'Recent #0' | cut -d= -f2 | sed 's| .*||' | cut -d '/' -f1 | |
} | |
function logpref() { | |
APP_ID=$(logPackageName) | |
echo "current packageName:$APP_ID" | |
SHARED_PREF_FILES=$(adb shell "run-as $APP_ID ls /data/data/${APP_ID}/shared_prefs/") | |
SHARED_PREF_FILE=${SHARED_PREF_FILE[0]} | |
echo "current preference file:$SHARED_PREF_FILE" | |
echo "content:" | |
adb shell "run-as $APP_ID cat /data/data/${APP_ID}/shared_prefs/$SHARED_PREF_FILE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment