1

Actually problem is that when i insert server images into Sdcard its gone and also display in sdcard but when i open phone Gallery it is not showing . I also use this code for invoke media scanner on button click ....

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+Environment.getExternalStoragePublicDirectory(Environment.MEDIA_MOUNTED))));

but its not working.

in case when i mount and unmount sdcard in device then after all images are shown. but i want when app is run images stored into sdcard and also show in device gallery.

pls help it much appreciate ..

Thanks ...

Vladimir
  • 3,774
  • 3
  • 23
  • 27

1 Answers1

0

The correct approach is to use MediaScannerConnection.scanFile(). See this answer with more details.

In short:

  1. Instantiate the MediaScannerConnection with a callback.
  2. Connect to it using connect().
  3. In the onMediaScannerConnected() callback, invoke scanFile(path, mimeType) to have the media scanner scan it. Note that the path is absolute and the mime type is optional (may be null).
  4. When you're done, disconnect the MediaScannerConnection, for instance when the onScanCompleted() callback is executed.
Community
  • 1
  • 1
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187