How to refresh Gallery after deleting image from SDCard

前端 未结 4 821
鱼传尺愫
鱼传尺愫 2020-12-16 02:21

When deleting the images on Android’s SD Card, sometimes the images are correctly removed but in the gallery still remains a preview of the removed image. When tapping on it

4条回答
  •  萌比男神i
    2020-12-16 02:37

    For each file while deleted use this

    KITKAT

    this worked for me

    try {
                context.getContentResolver().delete(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        MediaStore.Images.Media.DATA + "='"
                                + new File(fileUri).getPath() + "'", null);
            } catch (Exception e) {
                e.printStackTrace();
    
            }
    

提交回复
热议问题