0

Inspired by this example, I would like to delete a specific application's files (cache).
Here is the code:

       void DeleteRecursive() {
            String path="/sdcard/android/data/aaa.bb.cc/cache"
         File fileOrDirectory= new File(path);
        if (fileOrDirectory.isDirectory())
            for (File child : fileOrDirectory.listFiles())
                DeleteRecursive(child);

        fileOrDirectory.delete();
    }

But after deleting files when I go into the file manager, file still exists. What is wrong?

Community
  • 1
  • 1
madam
  • 119
  • 8
  • 2
    do you have the right permissions? – ligi Oct 22 '15 at 15:49
  • 1
    Android is permission based. If your app doesn't have the right permission to delete/modify/create files. Check the return value of delete, it will definately be false. – RvdK Oct 22 '15 at 15:51
  • @Antonio If you viewed the related question, you should have seen that the user is using the code from teedyay (http://stackoverflow.com/a/6425744/47351) The question is about why it does not delete. – RvdK Oct 22 '15 at 15:52
  • ligi and Rvdk Thank you very much for helping...i forget permisssions – madam Oct 22 '15 at 16:02

0 Answers0