Issue
Below command is to pull a file:
adb -d shell "run-as com.myapp cat /data/data/com.myapp/databases/file.db" > file.db
But how to push it back like Android Studio does via Device File Explorer?
Solution
There is no simple command for uploading the file. What Android Studio does when uploading a file using Device File Explorer is this:
- Upload the file via
adb push
to/data/local/tmp/<random file name>
- Execute
adb shell run-as com.myapp sh -c 'cp /data/local/tmp/<random file name> /data/data/com.myapp/<path>/<final file-name>'
- Delete the temp file via
adb shell rm /data/local/tmp/<random file name>
- Get the updated view for Device File Explorer using
adb shell run-as com.myapp sh -c 'ls -al /data/data/com.myapp/<path>/'
I discovered this by capturing the adb traffic on TCP port 5027 using Wireshark. An interesting detail is that each command executed using adb shell command uses the form <command-to-be executed in adb shell> || echo ERR-ERR-ERR-ERR
Answered By - Robert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.