Image not shown in gallery

I launch the default camera using intent and save these camera images to external storage using the following path:

File file = new File(Environment.getExternalStorageDirectory() + File.separator + fileName); 

But it does not appear in the gallery. The problem occurs in nexus 4.7 and moto G devices with OS 4.4.2

I'm trying with

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

But it does not work

+6
source share
3 answers

You will need to update the media scanner cache, try the following:

 sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(yourFile))); 
+1
source

You must tell the device to scan a new media file. Try this snippet:

 MediaScannerConnection.scanFile( this, new String[]{file.getAbsolutePath()}, null, null); 
0
source

I think you better make a folder in the default folder for the camera and put your data in it. Check if there is a file named ".nomedia" in this folder.

0
source

All Articles