mediastore - Android deleting the micro_kind thumbnails after image file deletion -
i populating gridview micro_kind thumbnails using following:
/* find images of interest */ imagecursor = getactivity().getcontentresolver().query(mediastore.images.media.external_con tent_uri, columns, mediastore.images.media.data + " ? ", new string[]{"%/housetab" + currenthousenumber + "/%"}, null); /* retrieve micro_kind thumbnails */ int id = imagecursor.getint(image_column_index); thumbnails[i] = mediastore.images.thumbnails.getthumbnail( getactivity().getapplicationcontext().getcontentresolver(), id, mediastore.images.thumbnails.micro_kind, null);
the retrieve process works perfectly; issue happen when delete actual image files can not delete micro_kind thumbnails. using right , files images gets deleted micro_kind not deleted , still visible in gridview after refresh. rid of thumbnail have turn off device or unmount/mount of sdcard.
int count = imagecursor.getcount(); int image_column_index = imagecursor.getcolumnindex(mediastore.images.media._id); contentresolver cr = getactivity().getapplicationcontext().getcontentresolver(); (int = 0; < count; i++) { new file(arrpath[i]).delete(); // delete actual image file imagecursor.movetoposition(i); long id = imagecursor.getint(image_column_index); /* delete thumbnails ???? not working */ cr.delete(mediastore.images.thumbnails.external_content_uri, mediastore.images.thumbnails.image_id + "= ?",new string[]{"" + id});
by way arrpath retrieve mediastore using following:
int datacolumnindex = imagecursor.getcolumnindex(mediastore.images.media.data); arrpath[i] = imagecursor.getstring(datacolumnindex);
i try following delete thumbnails without success.
mediascannerconnection.scanfile( getactivity().getapplicationcontext(), new string[]{arrpath[i]}, null, new mediascannerconnection.onscancompletedlistener() { @override public void onscancompleted(string path, uri uri) { refreshimages(); } });
so how remove entry database when imagecursor refreshed after file deletion imagecursor empty , no micro_kind or data matter returned???
any appreciated.
hopefully others. manage delete entry mediastore hence micro_kind thumbnails using following:
uri uri = contenturis.withappendedid(mediastore.images.media.external_content_uri, id); cr.delete(uri,null,null);