How can one pull the (private) data of one's own Android app?

前端 未结 14 1738
长发绾君心
长发绾君心 2020-11-30 16:44

Attempting to pull a single file using

adb pull /data/data/com.corp.appName/files/myFile.txt myFile.txt

fails with

failed          


        
14条回答
  •  攒了一身酷
    2020-11-30 17:23

    Similar to Tamas's answer, here is a one-liner for Mac OS X to fetch all of the files for app with your.app.id from your device and save them to (in this case) ~/Desktop/your.app.id:

    (
        id=your.app.id &&
        dest=~/Desktop &&
        adb shell "run-as $id cp -r /data/data/$id /sdcard" &&
        adb -d pull "/sdcard/$id" "$dest" &&
        if [ -n "$id" ]; then adb shell "rm -rf /sdcard/$id"; fi
    )
    
    • Exclude the -d to pull from emulator
    • Doesn't stomp your session variables
    • You can paste the whole block into Terminal.app (or remove newlines if desired)

提交回复
热议问题