Clear Android Download List

I am trying to make an application that will do some cleaning on my device, among other things, I would like it to delete all files that are in my directory Download

. I am using a method like this to delete files:

private static void deleteFiles(File path) {
    Util.Log("deleting all files underneath " + path.getName());
    if( path.exists() && path.isDirectory() ) {
        File[] files = path.listFiles();
        for(int i=0; i<files.length; i++) {
            if(files[i].isDirectory()) {
                Util.Log(files[i].getName() + " is a dir, being recursive.");
                deleteFiles(files[i]);
            }else {
                Util.Log(files[i].getName() + " is a file, deleting it.");
                files[i].delete();
            }
        }
    }
}

      

( ). "" , . , , : " . [ ] []. , . , - -, , , , " "" " , , .

A similar situation occurs when you delete images from the catalog DCIM

, they will still appear in the Gallery application after deletion. I was able to broadcast the MEDIA_MOUNTED intent that caused the Gallery app to update the current files (which then correctly removed the images from the Gallery app). However, MEDIA_MOUNTED doesn't seem to affect the Downloads app.

Is there anything on the same line that I can do to tell the Downloader that I want it to update its list based on the files currently present (or not present) in the directory /sdcard/Download/

?

+1


source to share


1 answer


In fact, you can clear the entries in the Download application. You can just use the method remove(id)

from DownloadManager. The only problem is that you probably don't have the referenceId of the uploaded file anymore. If you have a local Uri file or filename, you can simply ask the DownloadManager to download successfully and find the id. It seems very cumbersome, but it works.



+2


source







All Articles