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 tmpfile to ensure that these files are properly created in a temporary directory and cleaned-up at process end.
However, my investigations on various Android devices seem to indicate that
tmpfilealways fails;- there is no
/tmpdirectory; - directory
/data/local/tmpisn't present on all variants of Android; - there is no
TEMPenvironment variable set; mkstempdoesn't work any better thantmpfile.
Now, I'm sure that I could hack something together, but seeing that the SDK offers context.getCacheDir and File.createTempFile for Java applications, I hope that there is an equivalent at C-level.
Does anyone know of a good reliable and cross-Android method for creating a temporary file?