Android examples for android.media:Media File
get Output Media File Uri in yyyyMMdd_HHmmss format
import java.text.SimpleDateFormat; import java.util.Date; import android.content.ContentValues; import android.content.Context; import android.net.Uri; import android.provider.MediaStore; public class Main { public static Uri getOutputMediaFileUri(Context paramContext) { // give the image a name so we can store it in the phone's default location String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "IMG_" + timeStamp + ".jpg"); Uri uri = paramContext.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); // store // content // values return uri;// ww w . j a v a2 s .co m } }