Copying files in ADB shell with run-as

前端 未结 3 955
予麋鹿
予麋鹿 2020-12-01 16:57

Is there a way to write a script that will copy files from an ADB shell using run-as?

The only way I know of to copy in the adb shell is using cat source >

3条回答
  •  臣服心动
    2020-12-01 17:44

    you could just change the permission of the directory and then pull all the files out. but for me i was looking for just one shared preference file and i was able to get the data like this:

    PACKAGE='com.mypackage.cool'
    SHAREDPREF_FILE="${PACKAGE}_preferences.xml"
    
        adb shell "run-as $PACKAGE cat /data/data/$PACKAGE/shared_prefs/$SHAREDPREF_FILE">$SHAREDPREF_FILE
    

    now we have the data of the sharedpreference file stored in a file of the same name.

提交回复
热议问题