Java tutorial
//package com.java2s; import android.content.Context; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static File getTempFile(Context context) { File file = null; try { String fileName = "IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); file = File.createTempFile(fileName, ".jpg", context.getCacheDir()); } catch (IOException e) { e.printStackTrace(); } return file; } }