title: Android: Folder has many images but only single image is visible through gallery intent
body: <p>I am saving image bytes through my application using this simple method:</p>
  
  <pre><code>public static boolean StoreBytesToFile(byte[] messagebytes, String FilePathName)
  {
      try
      {
          FileOutputStream fos = new FileOutputStream(FilePathName);
          fos.write(messagebytes);
          fos.flush();
          fos.close();
      }
      catch(java.io.FileNotFoundException fnfe)
      {
          return false;
      }
      catch(java.io.IOException ioe)
      {
          return false;
      }
  
      return true;
  }
  </code></pre>
  
  <p>And then when user wants to see the stored image, I open it using gallery intent:</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setAction(Intent.ACTION_VIEW);
  Uri uri = Uri.parse("file://" + m_ImageFilename);
  intent.setDataAndType(uri, "image/*");
  startActivity(intent);
  </code></pre>
  
  <p>However, gallery shows only the single image file pointed by <code>m_ImageFilename</code> despite there are other images stored in the same folder.</p>
  
  <p>Thus actual behaviour of gallery intent is this:</p>
  
  <p><a href="https://i.stack.imgur.com/H4x7ql.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H4x7ql.jpg" alt="enter image description here"></a></p>
  
  <p>While expected behaviour is this:</p>
  
  <p><a href="https://i.stack.imgur.com/fdjndl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fdjndl.jpg" alt="enter image description here"></a></p>
  
  <p>As an important note, I must mention that <strong>after restarting phone, gallery intent shows all images in folder as expected.</strong> Also, the behaviour is same on all versions from  Jelly Bean to Marshmallow.</p>
  
  <p>So each time after saving image, user has to restart phone in order to see all images in folder through gallery intent.</p>
  
  <p>Please can someone tell what am I missing here and how can this be fixed?</p>