由于某种原因,无法在 Android 外部存储中创建新目录,我假设我缺少一些东西但无法在下面发现它是我用来尝试创建目录的代码,任何帮助都会有很大帮助,谢谢
Calendar calendarTime = Calendar.getInstance();
String newFolder = "/NewFolder/videos";
File newDirectory = new File(Environment
.getExternalStorageDirectory().toString() + newFolder);
newDirectory.mkdir();
File file = new File(newDirectory,
String.valueOf(calendarTime.getTimeInMillis()) + ".mp4");
if (camcorderProfile.fileFormat == MediaRecorder.OutputFormat.THREE_GPP) {
recorder.setOutputFile(file.getAbsolutePath());
} else if (camcorderProfile.fileFormat == MediaRecorder.OutputFormat.MPEG_4) {
recorder.setOutputFile(file.getAbsolutePath());
} else {
recorder.setOutputFile(file.getAbsolutePath());
}
在我的清单中
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"