I need to remove a particular folder from the /mnt/sdcard/new
.
I am looking at the folder with the DDMS in Eclipse.
How do we remove a particular folder.
Thanks in advance.
I need to remove a particular folder from the /mnt/sdcard/new
.
I am looking at the folder with the DDMS in Eclipse.
How do we remove a particular folder.
Thanks in advance.
You can use rm
command with -r
parameter to delete a nonempty folder.
C:\> adb shell
$ rm -r /mnt/sdcard/Android/data/mydirectory/
NOTE: rmdir
can delete only a nonempty folder.
Please use below method for delete folder from sdcard
// Deletes all files and subdirectories under dir.
// Returns true if all deletions were successful.
// If a deletion fails, the method stops attempting to delete and returns false.
public static boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
write below code for call deleteDir() method
// Delete an empty directory
boolean success = (new File("directorypath")).delete();
if (!success) {
// Deletion failed Message
}
boolean success = (
new File("/data/data/yourpackege/New Folder")).delete();
if (!success) {
// Deletion failed Message
Toast.makeText(getApplicationContext(),"not deleted : ", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext()," deleted : ", Toast.LENGTH_LONG).show();
}
If you want to delete any folder from ddms first you have to go to adb shell through cmd simple go to the path where your sdk\platform-tools\ is located ,there is your adb shell
to run command for deleting folders you must first root your device by simply typing
adb root
then you can delete the folder using
rmdir /mnt/sdcard/folder
to delete folder with files
rm -r /mnt/sdcard/folder
hope my answer will help anyone(beginners)