Programatically Deleted Files Still Show Up In Windows Explorer
Solution 1:
This is an old issue, but the above answers were not really helpful to me, so I tried some other stuff and the following worked for me.
Just call the scanFile
method of the MediaScannerConnection
on the file to be deleted after you delete it:
Filefile=newFile("...");
StringabsolutePathToFile= file.getAbsolutePath();
file.delete();
MediaScannerConnection.scanFile(context, newString[]{absolutePathToFile}, null, null);
I am guessing that the scanner scans the file location, does not find the file and updates the OS's file index or whatever takes care of making the files visible to the explorer.
Solution 2:
Android, being a Linux-based OS, will delete a file only when the last file handle to it is closed. The file name may disappear earlier, though.
On Windows, having an open file handle means the file name still exists. So Windows simply doesn't expect the file to disappear like it does.
Solution 3:
If the files are gone when you refresh, it may just be because Windows doesn't expect the directory to change out from underneath it, and so doesn't check for changes.
Post a Comment for "Programatically Deleted Files Still Show Up In Windows Explorer"