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

前端 未结 14 1733
长发绾君心
长发绾君心 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:28

    Newer versions of Android Studio include the Device File Explorer which I've found to be a handy GUI method of downloading files from my development Nexus 7.

    You Must make sure you have enabled USB Debugging on the device

    1. Click View > Tool Windows > Device File Explorer or click the Device File Explorer button in the tool window bar to open the Device File Explorer.
    2. Select a device from the drop down list.
    3. Interact with the device content in the file explorer window. Right-click on a file or directory to create a new file or directory, save the selected file or directory to your machine, upload, delete, or synchronize. Double-click a file to open it in Android Studio.

      Android Studio saves files you open this way in a temporary directory outside of your project. If you make modifications to a file you opened using the Device File Explorer, and would like to save your changes back to the device, you must manually upload the modified version of the file to the device.

    Full Documentation

    0 讨论(0)
  • 2020-11-30 17:32

    You may use this shell script below. It is able to pull files from app cache as well, not like the adb backup tool:

    #!/bin/sh
    
    if [ -z "$1" ]; then 
        echo "Sorry script requires an argument for the file you want to pull."
        exit 1
    fi
    
    adb shell "run-as com.corp.appName cat '/data/data/com.corp.appNamepp/$1' > '/sdcard/$1'"
    adb pull "/sdcard/$1"
    adb shell "rm '/sdcard/$1'"
    

    Then you can use it like this:

    ./pull.sh files/myFile.txt
    ./pull.sh cache/someCachedData.txt
    
    0 讨论(0)
提交回复
热议问题