How can I delete all files with a certain extension, for example .png using Android ADB?
Removing one file would be:
adb shell rm downloads/bg.png
But how can I delete all png images on the entire device?
It's very close to what #Robert mentioned in the comments
$ find -L /sdcard -name "*.png" -exec rm {} \; 2>/dev/null
the only catch is that /sdcard is a symlink so you have to follow them (-L).
I already have this code, but I don't know how to infinite delete the folder.
#!/system/bin/sh
rm -r /data/data/com.tencent.ig/files/tss_tmp
touch /data/data/com.tencent.ig/files/tss_tmp
I'm using an app on playstore.
well i just solve my own question
#!/system/bin/sh
while true
do
rm -r /data/data/com.tencent.ig/files/tss_tmp
touch /data/data/com.tencent.ig/files/tss_tmp
done
I need to delete my database using shell. Please help me find the command to DROP/DELETE my wsemp database. I have tried DROP wsemp, DELETE wsemp etc but not working.
You can delete your SQLite database using shell command as below:
adb shell
cd /data/data
cd <your.application.java.package>
cd Databases
rm <your db name>
For more details check out Examining sqlite3 databases from a remote shell
Can't you just delete the database file?
Use DDMS in Eclipse.
Or in a shell (emulator or rooted device)
adb shell
cd /data/data
cd <your.application.java.package>
cd Databases
rm wsemp
or in code
context.deleteDatabase("wsemp");
I want to rename the folder from DDMS. The DDMS only supports deletion of a file and an empty folder. I want to change the name of folder /mnt/sdcard/NewFolder to /mnt/sdcard/NewFolder2. Is there a way to rename the folder?
Use the following command in cmd:
C:\> adb shell
$ cd /mnt/sdcard
$ mv NewFolder NewFolder2
I created several folders in the sdcard (Eclipse) by running an Android application in the emulator. Now I want to delete the folders which I have created on the sdcard.
I am able to delete files in the folders but I could not delete the folders in the sdcard.
How can I do this? Is there a way to delete folders?
Using adb command you can delete folders.
click Run - > CMD-> type adb shell --> cd sdcard -> rmdir {dirname}
Note : Make sure your dir should be empty.
For non-empty directory use.
click Run - > CMD-> type adb shell --> cd sdcard -> rm -r {dirname}
Well, answer from Brijesh Thakur is really helpful.
I just tried this and it worked fine for me to some extent. I would like to mention that if your directory contains any files then the rmdir command will not work. You will have to use rm -r command for that.
To make it more easy for beginners I am explaining the process as follows.
First you need to locate your adb folder, mine was at D:\Android SDK\platform-tools>
Now execute adb shell in a command prompt as:
D:\Android SDK\platform-tools>adb shell
A hash (#) symbol or dollar sign ($) will appear, then enter the following command:
# cd sdcard
Now you are in the sdcard of the device. If your folder is a sub folder then further locate its parent folder using the cd command. Finally, use the rm -r command to remove the folder recursively as follows. This will delete all files and directories in the folder.
# rm -r FolderName
Please note that if you want to remove a single file you can use the rm command only and then the file name (with extension probably). And you can also use rmdir command if the directory you trying to delete is empty.
Using adb shell with rm command you can delete(nonempty as well as empty) folders.
click Run -- > CMD--> type adb shell --> cd sdcard --> rm -r {dirname}
We can do it in a single command line as under:
adb shell rm -r sdcard/<dirname>
If you want to delete everything in your android file system, you need to get its storage name from adb!
# adb shell echo $EXTERNAL_STORAGE
It will give you the path where everything is stored!It will print the storage name in command line, for few devices it is /sdcard and for few, it is /storage/emulated/legacy etc
Now you want to delete everything in that, you need
# adb shell rm -r /sdcard/
that /sdcard/ is not same for all devices, it could be /storage/emulated/legacy/ for some devices!
warning-: It will delete every folder in your file manager except "android" folder
now if you want to delete a particular folder in that file manager
# adb shell rm -r /sdcard/FolderName
remount the sdcard with read and write permission:
adb shell mount -o remount,rw /
Go to adb shell:
adb shell
Delete file you want:
rm -r /sdcard/file_name
It will work most better.