我在Fragment中使用此方法并获得此错误,但在活动中它运行良好,我该如何解决这个问题?
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "AA");
if (!mediaStorageDir.exists()) {
if (`!mediaStorageDir.mkdirs()) {//I get the exception here`
return null;
}
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
return Uri.fromFile(mediaFile);