title: Android KitKat MediaScannerConnection not finding images saved to private app folder
body: <p>I have an app which performs processing on an image selected by the user using from the gallery, after processing the modified image is then saved back to the original image's folder with a modified filename. On specific devices (mainly Samsungs) the new KitKat permission limitations severely limit where a non system app can write to e.g. external SD card or back to typical gallery locations.
  The documentation advises to write to the private package specific folder obtained via </p>
  
  <pre><code>getExternalFilesDir(null)
  </code></pre>
  
  <p>This is fine and the image is saved correctly but then a subsequent call to</p>
  
  <pre><code>MediaScannerConnection.scanFile
  </code></pre>
  
  <p>fails to update the central media database correctly as the modified image doesn't appear in the gallery, even a reboot of the device which should force a full scan of all media doesn't trigger the image to be displayed.</p>
  
  <p>In other words the following code doesn't work:</p>
  
  <pre><code>File appDir = MyActivity.this.getExternalFilesDir(null);
  File file = new File(appDir, "new_image.jpeg");
  // Process image and write file away...
  MediaScannerConnection.scanFile(this, new String[] { file.getAbsolutePath() }, null, new        MediaScannerConnection.OnScanCompletedListener() {
    @Override
    public void onScanCompleted(String path, Uri uri) {
      Log.i(LOG_TAG, String.format("Scanned file: %s", path));
    }
  });
  </code></pre>
  
  <p>The onScanCompleted method fires but the gallery doesn't show the new image.</p>
  
  <p>Has anyone seen this behaviour, does MediaScanner not scan 'private' app folders and if so how else do I get the gallery to detect and display the new image.</p>