Reputation: 2672
I need to delete a file(video file) saved on my android gallery. I used file.delete();. The file is deleted in some devices. In some devices like Galaxy S the status of the file says it is deleted, but it is still present in the gallery. But the video can't be played!
I found that the media gallery is doing some aggressive caching of some preview/thumbnail, so that you see it there, but can not play it - as the underlying file is gone. How to delete this cache?
Upvotes: 1
Views: 3909
Reputation: 1261
You can send a broadcast to scan your image/video file by MediaScanner.
File f1 = new File("pathToYourFile");
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
scanIntent.setData(Uri.fromFile(f1));
sendBroadcast(scanIntent);
Note: Sending a broadcast after deleting the file will force MediaScanner to check for existence of that file to which it will detect that the file does not exist more and same will be reflected in Gallery.
Next thing you can do is to clear Gallery app's cache.
Upvotes: 2