0
이 코드를 Genotion Marshmallow와 Nougat로 HTC 10에서 테스트했는데,이 코드는 모두 작동했습니다.
이제 Genymotion에서 Android 7.0을 시도했지만 디렉토리를 만들지 않았습니다.특정 안드로이드 버전에서 디렉토리 만들기
왜 그런가?
File file = new File(Environment
.getExternalStorageDirectory() + File.separator +
"SchoolAssist" + File.separator + lesson_name);
boolean isDir = file.exists();
if (!isDir)
isDir = file.mkdirs();
if (isDir) {
Intent notes = new Intent(getActivity(), NotesManager.class);
notes.putExtra("dir", file.getAbsolutePath());
startActivity(notes);
}
else
Toast.makeText(getContext(), "Error creating directory", Toast.LENGTH_SHORT).show();
편집 : 디렉토리가 일을 만들 때 코드에서
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
당신이 바로 마지막 장치에 권한을 부여하는 것을 잊었다 가능성이 있습니까? –
어떤 장치에 대해서도 절대 권한을 요구하지 않았습니다. –
'API> = 23' - https://developer.android.com/training/permissions/requesting.html에서 코드의 권한을 확인해야합니다. –