Android File Create getOutputMediaFile(Context context)

Here you can find the source of getOutputMediaFile(Context context)

Description

get Output Media File

Declaration

private static File getOutputMediaFile(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;

import android.os.Environment;
import java.io.File;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static File getOutputMediaFile(Context context) {
        File mediaStorageDir = Environment
                .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

        // Create the storage directory if it does not exist
        if (!mediaStorageDir.exists()) {
            if (!mediaStorageDir.mkdirs()) {
                return null;
            }/*ww w.jav  a 2  s .  co m*/
        }
        // Create a media file name
        String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm")
                .format(new Date());
        File mediaFile;
        String mImageName = "TCG_" + timeStamp + ".jpg";
        mediaFile = new File(mediaStorageDir.getPath() + File.separator
                + mImageName);
        return mediaFile;
    }
}

Related

  1. ensureWorldReadable(File f)
  2. ensureWorldWriteable(File f)
  3. ensureWriteable(File f)
  4. getFile(File basedir, String path)
  5. getFile(String filepath)
  6. makeFile(File file)
  7. makeFile(String destinctionFile)
  8. overwriteFile(File file)
  9. verifyCanCreateFile(final String path, final long length)