You can do something like,
This works in my case..
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
startActivityForResult(intent, TAKE_PHOTO_CODE);
And getImageUri()
/**
* Get the uri of the captured file
* @return A Uri which path is the path of an image file, stored on the dcim folder
*/
private Uri getImageUri() {
// Store image in dcim
// Here you can change yourinternal storage path to store those images..
File file = new File(Environment.getExternalStorageDirectory() + "/DCIM", CAPTURE_TITLE);
Uri imgUri = Uri.fromFile(file);
return imgUri;
}
For more info look at How to capture an image and store it with the native Android Camera
EDIT:
In my code I store images on SDCARD
but you can give Internal storage path as per your need, like, /data/data/<package_name>/files/
..
You can use Context.getFilesDir()
. But keep in mind that even that is by default private to your app, so other applications (including the media store) will not be able to access it. That said, you always have the option to make files world read or writeable.
also Context.getDir()
with Context.MODE_WORLD_WRITEABLE
to write a directory that other apps can write into. But again, I question the need to store image data in local storage. Users won't appreciate that, unless users are expected to not have their SD card mounted while using your app (which is not common).