Push files through the adb command

foreword

Recently, in the project development, some files need to be transferred to the Android directory, so I explored the use of adb push and adb poll. After groping, make a record.

First of all, let me declare that these two usage methods can only be used when there is only one device in the adb device list, otherwise you need to bring the ip

Since adb push means to transfer to the device, and adb poll means to transfer to the outside of the device, but the usage of both is to transfer from address 1 to address 2. Therefore, only adb push is introduced.

adb push

when transferring files

You can specify the name of the file at the target location. At this time, the file will be overwritten. It is not required that the suffix of the target file to be transferred is consistent with the file to be transferred. For example, it is equivalent to renaming after transferring to the destination
adb push C:\Users\Administrator\Desktop\123.txt /sdcard/test/321.c
.

You can also omit the name of the target location. In this case, a file with the same name as the transfer file will be generated at the target location, and the file with the same name as the destination will also be overwritten. For example:
adb push C:\Users\Administrator\Desktop\123.txt /sdcard/test/

when transferring folders

When transferring a folder, only a subdirectory with the same name will be generated under the destination directory, no matter whether it contains a slash at the end before the transfer, for example: the
adb push C:\Users\Administrator\Desktop\video\ /sdcard/test/
above statement will be added in the test file regardless of whether a slash is added after video or test. Create a folder called video in the directory, and contain the original content in video.

If you want to transfer the files in the folder instead of the transfer folder, you need to add \.for example:
adb push C:\Users\Administrator\Desktop\video\. /sdcard/test/
At this time, the contents of the video folder will be placed under the test folder.

epilogue

After roughly testing the above content, it is basically simple enough to use. If multiple devices are connected and you want to specify one for transmission, then the command needs to be added directly to adb and -s deviceIdpush adb devices. Name (possibly ip address + port)
command such as:adb -s 192.168.10.12:5432 push

おすすめ

転載: blog.csdn.net/ex_xyz/article/details/121469154
おすすめ