Android - Why my saved image is not appearing in the default gallery of my phone?

前端 未结 5 988
时光说笑
时光说笑 2021-01-14 01:44

I am trying to save an image from my application to the default gallery of my phone. The code below works perfectly if I have a SD card on the phone. The image saved appears

5条回答
  •  半阙折子戏
    2021-01-14 02:28

    Another easy way to do it. Add this after saving your file.

    File imageFile = ...
    MediaScannerConnection.scanFile(this, new String[] { imageFile.getPath() }, new String[] { "image/jpeg" }, null);
    

提交回复
热议问题