I am deleting an image file from my application. I was doing
new File(filename).delete ();
This was actually deleting the file. But the image was still visible in the gallery.
On search i found that we should use
getContentResolver().delete(Uri.fromFile(file), null,null); to delete
But here i am getting the exception:
Unknown file URL. java.lang.IllegalArgumentException: Unknown URL
file:///mnt/sdcard/DCIM/Camera/IMG_20120523_122612.jpg
When i see with any file browser, this particular image is present. Please help me to fix this issue. Is there any other way to update gallery when image is physically deleted
Use the code below, it may help you.
to refresh gallery after deleting image use below code for send Broadcast
(for < KITKAT API 14)
For >= KITKAT API 14 use below code
Because:
is deprecated in KITKAT(API 14).
EDITED 04-09-2015
its working fine check below code
below is logs