I am trying to remove a file on my android using a single ADB command.
I understand you can just do adb shell and then remove the file using rm.
But I need it to be a one line execution.
I’ve tried:
adb rm-f /directory/file.txt
adb shell rm-f /directory/file.txt
Both don’t delete the file I want.
Disconnect the USB connection—or turn off the device's Wi-Fi if you're connected over Wi-Fi. Close Android Studio/Eclipse/other IDE. Run adb kill-server to ensure adb is not running. Restart your Android device.
Delete file on android:
adb shell rm sdcard/download/file.ext
I noticed in your comments you are looking for one line execution since you're gonna be using Python. Well as an alternative you could use the subprocess module to write to stdout allowing you to execute as many commands of choice
for example
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With