CreateTempFile returns No Such File or Directory in Pictures folder?
<p>So here is my code:</p>

<pre><code>String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
      imageFileName,  /* prefix */
      ".jpg",         /* suffix */
      storageDir      /* directory */
);
</code></pre>

<p>However, my application intermittently throws error at <code>File.createTempFile</code>:</p>

<pre><code>java.io.IOException: open failed: ENOENT (No such file or directory).
</code></pre>

<p>From the documentation of <code>File</code>:</p>

<pre><code>Parameters:
prefix the prefix to the temp file name.
suffix the suffix to the temp file name.
directory the location to which the temp file is to be written, or null for the default location for temporary files, which is taken from the "java.io.tmpdir" system property. It may be necessary to set this property to an existing, writable directory for this method to work properly.

Returns:
the temporary file.

Throws:
IllegalArgumentException - if the length of prefix is less than 3.
IOException - if an error occurs when writing the file.
</code></pre>

<p>What are the possibilities of failing writing the temporary file? Since I point to external storage and my external sd card is plugged inside device.</p>