Java tutorial
//package com.java2s; //License from project: Apache License 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) { } return file; } }