title: Creating temporary files in Android with NDK
body: <p>I am currently working on a C-based, NDK-based, Android application. This application needs to create temporary files. On a regular Linux system, I would use <code>tmpfile</code> to ensure that these files are properly created in a temporary directory and cleaned-up at process end.</p>
  
  <p>However, my investigations on various Android devices seem to indicate that</p>
  
  <ul>
  <li><code>tmpfile</code> always fails;</li>
  <li>there is no <code>/tmp</code> directory;</li>
  <li>directory <code>/data/local/tmp</code> isn't present on all variants of Android;</li>
  <li>there is no <code>TEMP</code> environment variable set;</li>
  <li><code>mkstemp</code> doesn't work any better than <code>tmpfile</code>.</li>
  </ul>
  
  <p>Now, I'm sure that I could hack something together, but seeing that the SDK offers <code>context.getCacheDir</code> and <code>File.createTempFile</code> for Java applications, I hope that there is an equivalent at C-level.</p>
  
  <p>Does anyone know of a good reliable and cross-Android method for creating a temporary file?</p>