List of usage examples for android.os Environment DIRECTORY_PICTURES
String DIRECTORY_PICTURES
To view the source code for android.os Environment DIRECTORY_PICTURES.
Click Source Link
From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java
private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); String imageFileNamePrefix = "chathub-" + timeStamp; File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); File imageFile = File.createTempFile(imageFileNamePrefix, /* prefix */ ".jpg", /* suffix */ storageDir /* directory */ );/*from w w w . ja v a 2s. c o m*/ return imageFile; }
From source file:com.mobantica.DriverItRide.activities.ActivityProfile.java
private static File getOutputMediaFile(int type) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), IMAGE_DIRECTORY_NAME);/*from w ww.j a v a 2 s . c o m*/ try { if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create " + IMAGE_DIRECTORY_NAME + " directory"); return null; } } } catch (Exception e) { e.printStackTrace(); } String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE) { mediaFile = new File(mediaStorageDir.getPath() + "/" + "IMG_" + timeStamp + ".jpg"); } else { return null; } return mediaFile; }
From source file:info.papdt.blacklight.support.Utility.java
/** Create a File for saving an image*/ private static File getOutputImageFile() { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "BlackLight"); // This location works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d(TAG, "failed to create directory"); return null; }//from w w w . jav a2 s. c o m } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); return mediaFile; }
From source file:org.artoolkit.ar.samples.ARMovie.ARMovieActivity.java
private static File createDataFolders() { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "ARCloud"); boolean isFolderExisted = false; if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("ARCloud", "failed to create directory 1"); isFolderExisted = false;//from ww w.j ava 2s. c o m return null; } else { isFolderExisted = true; } } else { isFolderExisted = true; } Log.d("ARCloud", mediaStorageDir.getPath()); if (isFolderExisted) { File dataDir = new File(mediaStorageDir.getPath(), "Data"); if (!dataDir.exists()) { if (!dataDir.mkdirs()) { return null; } } File dataNFTDir = new File(mediaStorageDir.getPath(), "DataNFT"); if (!dataNFTDir.exists()) { if (!dataNFTDir.mkdirs()) { return null; } } } return mediaStorageDir; }
From source file:com.bai.android.ui.OtherActivity.java
private Uri getOutputMediaFileUri() { // To be safe, you should check that the SDCard is mounted // using Environment.getExternalStorageState() before doing this. File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "WasedaMobile"); // This location works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Toast.makeText(getApplicationContext(), "Failed to create directory", Toast.LENGTH_LONG).show(); return null; }//from w ww .jav a 2 s. c om } // Create a media file name File mediaFile; mediaFile = new File(mediaStorageDir.getPath() + File.separator + "WasedaMobile_Temp.jpg"); return Uri.fromFile(mediaFile); }
From source file:mgks.os.webview.MainActivity.java
private File create_image() throws IOException { @SuppressLint("SimpleDateFormat") String file_name = new SimpleDateFormat("yyyy_mm_ss").format(new Date()); String new_name = "file_" + file_name + "_"; File sd_directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); return File.createTempFile(new_name, ".jpg", sd_directory); }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * Returns the path to the directory in which the images are saved. * * @param appName name of the app, this is used for gathering the directory string. * @return the path where the images are stored. *///from ww w.ja v a2 s. c o m public static File getMediaStorageDir(String appName) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appName); // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { return null; } } return mediaStorageDir; }
From source file:com.lastsoft.plog.GamesFragment.java
private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String fileName = "PLAY_" + timeStamp + "_"; String imageFileName = fileName; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File plogDir = new File(storageDir, "/Plog/"); File image = File.createTempFile(imageFileName, ".jpg", plogDir); // Save a file: path for use with ACTION_VIEW intents mCurrentPhotoPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Plog/" + image.getName();//from ww w .j a v a 2 s . c o m return image; }
From source file:com.ereinecke.eatsafe.MainActivity.java
/** Returns a unique, opened file for image; sets photoReceived with filespec */ private File openOutputMediaFile() { String appName = App.getContext().getString(R.string.app_name); if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return null; }// w w w .j av a 2s . c o m File mediaStorageDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), appName); Logd(LOG_TAG, "mediaStorageDir: " + mediaStorageDir.toString()); // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Logd(LOG_TAG, "failed to create directory " + mediaStorageDir); return null; } } // Create a media file name @SuppressLint("SimpleDateFormat") String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String fileName = Constants.IMG_PREFIX + timeStamp; File imageFile = null; // Open a temp file to pass to Camera try { imageFile = File.createTempFile(fileName, ".jpg", mediaStorageDir); Logd(LOG_TAG, "imageFile: " + imageFile); } catch (IOException e) { e.printStackTrace(); Logd(LOG_TAG, e.getMessage()); } // Generate a file: path for use with intent if (imageFile != null) { URI uri = imageFile.toURI(); photoReceived = Uri.parse(uri.toString()); } return imageFile; }
From source file:es.upv.riromu.arbre.main.MainActivity.java
/** * CreateImageFile/*from w w w.ja v a 2 s .c om*/ */ private File createJSONFile(String JSON) throws IOException { // Create an image file name String timeStamp = String.valueOf(System.currentTimeMillis() / 1000L); String imageFileName = "PLATANUS" + timeStamp; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File file = File.createTempFile(imageFileName, /* prefix */ ".txt", /* suffix */ storageDir /* directory */ ); FileWriter filewriter = new FileWriter(file); filewriter.write(JSON); filewriter.flush(); filewriter.close(); // Save a file: path for use with ACTION_VIEW intents return file; }