get Output File from External Storage Directory - Android android.os

Android examples for android.os:External Storage

Description

get Output File from External Storage Directory

Demo Code

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.os.Environment;

public class Main {

  static File getOutputFile() {
    File storage = new File(Environment.getExternalStorageDirectory(), "BasinMirror");
    storage.mkdirs();//from   w  w  w .j  av a 2  s  .co  m
    String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
    return new File(storage, "IMG_" + timestamp + ".jpg");
  }

}

Related Tutorials