如何使用ADB命令将文件从计算机推送到/Data/.../databases/?
下面的命令是提取文件:
adb -d shell "run-as com.myapp cat /data/data/com.myapp/databases/file.db" > file.db
但是如何像Android Studio通过设备文件资源管理器一样将其推回?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有简单的命令可以上传文件。 Android Studio使用设备文件资源管理器上传文件时会做什么:
adb push/data/local/tmp/<随机文件名>
adb shell run-as 上传文件。 com.myapp sh -c'cp/data/local/tmp/<随机文件名> /data/data/com.myapp//path ;/> final file-name>'
adb shell shell rm/data/local/tmp/tmp/tmp/tmp< andy files>
adb shell run -as com.myapp sh -c'ls -al/data/data/com.myapp/com.myapp/<;
我通过使用Wireshark在TCP端口5027上捕获ADB流量来发现这一点。一个有趣的细节是,使用adb shell命令执行的每个命令使用form
&lt;命令 - 命令在adb shell&gt;中执行。 || Echo Err-err-err-err
There is no simple command for uploading the file. What Android Studio does when uploading a file using Device File Explorer is this:
adb push /data/local/tmp/<random file name>
adb shell run-as com.myapp sh -c 'cp /data/local/tmp/<random file name> /data/data/com.myapp/<path>/<final file-name>'
adb shell rm /data/local/tmp/<random file name>
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
使用此命令
adb push&lt; file_path&gt; &lt; android_device_path&gt; gt;
adb pull&lt; android_device_path&gt; gt;
Use this command
adb push <file_path> <android_device_path>
adb pull <android_device_path>
从罗伯特的答案中,我可以这样做:
只需在您的 .bash_profile 中写上述代码行,然后在终端中调用它。
目前,我更喜欢使用Visual Studio代码,而不是Android Studio来开发我的Android应用程序。因此,我需要更多地了解终端中的命令,例如ADB,Gradle等。
我希望这对每个人都有用。
From Robert's answer now I can do like this:
Just write above code lines in your .bash_profile and then call it in terminal.
At this moment I prefer to use Visual Studio Code than Android Studio to develop my Android apps. So, I need to know more about commands in terminal, e.g. adb, gradle, etc.
I hope this would be useful for everyone.