Delete Photo Thumbnail In Gallery After Manually Delete The Photo File
case R.id.menu_delete: File photoToDelete = new File(photoPath, photoList[gPosition]); photoToDelete.delete(); checkPhotoFolder(); galleryAdapter.notifyDataSetChang
Solution 1:
Try invoke the MediaScanner to refresh the gallery
// Tell the media scanner about the new file so that it is// immediately available to the user.MediaScannerConnection.scanFile(this,
newString[] { file.toString() }, null,
newMediaScannerConnection.OnScanCompletedListener() {
publicvoidonScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
}
});
Code from Google's example
Solution 2:
Solution 3:
You must update the data structure (eg. list or array) that stores the photos.
I guess it is photoList
.
So you should do (assuming photoList
is an array):
photoList = photoList.asList().remove(gPosition).toArray();
Post a Comment for "Delete Photo Thumbnail In Gallery After Manually Delete The Photo File"