I want to create and delete some files located in /data/data/providers/downloads/cache. So far, I can download target files and save in /data/data/providers/downloads/cache successfully, but when I trying to delete a file located in /data/data/providers/downloads/cache it fails in the end. My methods are as follows
File directory = new File("/data/data/providers/downloads/cache");
File[] files = directory.listFiles();
I want to list all files, so that I can find the target files need to be deleted.
I found that listFiles() method always return NULL, so my question is, can I use listFile() to the dir /data/data/providers/downloads/cache ?
Any ideals are welcomed.
BR
Alan
I use this method: when i want to delete all the files including the directory.
But android has it’s own clear cache method you can use, but it requires you to actually save stuff to the cache. The problem might be that you never add anything to it, and you only have permission to clear your own cache?
How do I take advantage of Android's "Clear Cache" button Discusses the problem anyway 🙂
Good luck
EDIT:
Also, are you sure your file path is correct? You can use
in order to find the root directory to the cache i think?