-1

I am using Camera Intent with following code

    public void clickPicturesThroughCamera() {
    try {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        initImageUri();
        intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
        startActivityForResult(intent, RETURN_FROM_CAMERA);
    } catch (Exception e) {
        showToast(getString(R.string.error_opening_camera));
    }
 }


    public void initImageUri() {
    ContentValues cv = new ContentValues();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat,
            Locale.ENGLISH);
    String name =simpleDateFormat.format(Calendar.getInstance().getTime())
            + "_" + new Random().nextInt(100) + ".jpg";
    cv.put(MediaStore.Images.Media.TITLE, name);
    imageUri = getContentResolver().insert(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv);

}

The images captured will be stored on /storage/sdcard0/DCIM/Camera/imagename.jpg. But when I click images through default Camera app it will be stored on storage/extSdCard/DCIM/Camera/imagename.jpg as I have used external sdcard to store the the captured images by default.

So my main requirment is that the app I am developing should store the captured images on the default location i.e. storage/extSdCard/DCIM/Camera/imagename.jpg instead of /storage/sdcard0/DCIM/Camera/imagename.jpg. For that what should I do in the above code, so that it will always save the images on default Camera folder.

Thanks

laaptu
  • 2,963
  • 5
  • 30
  • 49

1 Answers1

0

The path can vary among devices. By using MediaStore.Images.Media.EXTERNAL_CONTENT_URI you are asking the device for the correct path.

http://developer.android.com/reference/android/provider/MediaStore.Images.Media.html

Yale
  • 333
  • 3
  • 7