我正试图使用单个ADB命令在我的安卓设备上删除一个文件。
我知道你可以使用adb shell然后使用rm删除文件。
但我需要它成为一行命令执行。
我已经尝试过:
adb rm-f /directory/file.txt
adb shell rm-f /directory/file.txt
都不要删除我想要的文件。不要删除。
在安卓上删除文件:
adb shell rm sdcard/download/file.ext
import subprocess
process = subprocess.Popen([r'adb', 'arg1', 'arg2'], stdout=subprocess.PIPE,stdin=
subprocess.PIPE) #start adb
process.stdin.write('shell \n') # Parse in input into the program
process.stdin.write('rm *\n') # Parse in second input
line=process.stdout.readline() # Read a line from stdout
对我来说,运行以下命令有效:
adb shell rm -f -rR -v /sdcard/Documents/
adb shell
,然后按回车键,接着输入下一个命令rm -f /sdcard/test.txt
。 - Ashvin solanki