gallery - Android keeps thumbnails for deleted images and they appear when I request them, but original files dont -
in application obtain image thumbnails device show in custom gallery mediastore
getloadermanager().initloader(cursorloader_thumbs, null, this); getloadermanager().initloader(cursorloader_real, null, this); @override public loader<cursor> oncreateloader(int cursorid, bundle arg1) { cursorloader cl = null; arraylist<string> img = new arraylist<string>(); switch (cursorid) { case cursorloader_thumbs: img.add(mediastore.images.media._id); break; case cursorloader_real: img.add(mediastore.images.thumbnails.data); break; default: break; } cl = new cursorloader(application, mediastore.images.media.external_content_uri, img.toarray(new string[img.size()]), null, null, null); return cl; } private string getpathofthumbnailbyid(context context, int id) { cursor cursor = context.getcontentresolver().query(mediastore.images.media.external_content_uri, new string[] { mediastore.images.media.data }, mediastore.images.media._id + "=?", new string[] { "" + id }, null); if (cursor != null && cursor.getcount() > 0) { cursor.movetofirst(); string fullpath = cursor.getstring(0); cursor.close(); return fullpath; } else { return ""; } }
but if user goes folder , deletes image, android doesnt delete corresponding thumbnail gallery app keeps showing thumbnail, user clicks on it, , no image found.
just put code in onresume() when user leave app deleteing image , after deleting image user come app , onreume() call , app refresh images.
Comments
Post a Comment