Java tutorial
//package com.java2s; import java.io.File; import java.io.IOException; import android.content.Context; public class Main { /** * Creates temporary file in external storage, or in case when extrnal storage is not available * temporary file is created in the internal storage. * @param context - Context * @return instance of java.io.File or null if error occured. */ public static File createTempFile(Context context) { if (context == null) throw new IllegalArgumentException(); File saveToDir = context.getExternalCacheDir(); if (saveToDir == null) { saveToDir = context.getCacheDir(); } File tempFile = null; try { tempFile = File.createTempFile("parrot", "", saveToDir); } catch (IOException e) { e.printStackTrace(); return null; } return tempFile; } }