I have a problem with the following script. It is saving the image in the folder i want it to but it is also saving it to DCIM folder, thing that i don't want. So what do i have to change to save it only into my folder?
**
- save photo
**
private static File getOutputMediaFile(int type) {
// External sdcard location
File mediaStorageDir = new File(
// Environment.getDataDirectory()(Environment.)
Environment.getExternalStorageDirectory().toString()
+ "/Android/data/com.itbstudios.shoppinglist/Shopping List");
// Create the storage directory if it does not exist
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create "
+ IMAGE_DIRECTORY_NAME + " directory");
return null;
}
}
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.getDefault()).format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE) {
mediaFile = new File(mediaStorageDir.getPath() + File.separator
+ "IMG_" + timeStamp + ".itb");
} else {
return null;
}
return mediaFile;
}
**
- take photo
**
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
startActivityForResult(intent, 100);
Thank you!
My strategy: Capture the photo as described in the question, save it into the internal memory (data/data/com.package...) After that delete it from the public folder (DCIM/MEDIA/100MEDIA) with the following method (delete last taken picture from that folder...):