/** Get a File for saving an image or video */ private File getOutputImageFile() { String YOUR_FIRST_NAME = "YourFirstName"; // Example: "Prakhar" // To be safe, you should check that the SDCard is mounted. String state = Environment.getExternalStorageState(); if (!Environment.MEDIA_MOUNTED.equals(state)) { Toast.makeText(this, "SD Card not mounted!", Toast.LENGTH_LONG).show(); return null; } // SD Card works best if you want the created images to be shared // between applications and persist after your app has been uninstalled. File imageStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), YOUR_FIRST_NAME); // Create the storage directory if it does not exist if (!imageStorageDir.exists() && !imageStorageDir.mkdirs()) { Toast.makeText(this, "Failed to create directory in SD Card", Toast.LENGTH_LONG).show(); return null; } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); File imageFile = new File(imageStorageDir.getPath() + File.separator + YOUR_FIRST_NAME + "_" + timeStamp + ".jpg"); return imageFile; }