I want the users of my application to be able to delete the DCIM folder (which is located on the SD card and contains subfolders).
Is this possible, if so how?
I want the users of my application to be able to delete the DCIM folder (which is located on the SD card and contains subfolders).
Is this possible, if so how?
Your approach is decent for a folder that only contains files, but if you are looking for a scenario that also contains subfolders then recursion is needed
Also you should capture the return value of the return to make sure you are allowed to delete the file
and include
in your manifest
You can not delete the directory if it has subdirectories or files in Java. Try this two-line simple solution. This will delete the directory and contests inside the directory.
Add this line in gradle file and sync the project
Simple way to delete all file from directory :
It is generic function for delete all images from directory by calling only
deleteAllImageFile(context);
use below method to delete entire main directory which contains files and it's sub directory. After calling this method once again call delete() directory of your main directory.
This is what I do... (terse and tested)