the camera app that i'm writing has the permissions WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
both.
i use the getExternalStorageDirectory()
method to write files to main directory of SD Card. I'm not running it on emulator. My device is Xperia Z3C
and has Android 6.0.1
.
when i have the path that getExternalStorageDirectory()
's given is "/storage/emulated/0/".
Then the files are saved on internal storage main directory.
private static File getOutputMediaFile(int type){
File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), "Flash");
Log.d("adasd", mediaStorageDir.getAbsolutePath());
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
Log.d("MyCameraApp", "failed to create directory");
return null;
}
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");
} else if(type == MEDIA_TYPE_VIDEO) {
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"VID_"+ timeStamp + ".mp4");
} else {
return null;
}
return mediaFile;
}