无法在API 19中的模拟器上创建文件,但在手机API 19上可以。 在API 24中的模拟器上,它很好,但在API 19上我无法创建一个文件。 清单:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
返回TURE:
private boolean externalStorageAvailable() {
return
Environment.MEDIA_MOUNTED
.equals(Environment.getExternalStorageState());
}
获取filePath:
String path = ((AppCallRecordFragment) getView()).getActivity().getExternalFilesDir(Environment.DIRECTORY_MUSIC).getPath();
String fileName = mStorage.getRecordInfo().get(0) + " " +
mStorage.getRecordInfo().get(1) + " " +
mStorage.getRecordInfo().get(2) +
".mp3";
return path + "/" + fileName;
}
filePath = /storage/sdcard/Android/data/evoytenkoapps.ru.MangoMobile/files/Music/08.06.18 11:44:33 Старцев Юрий 02 111111111.mp3
但是这返回空文件:
String filePath = getFilePath();
File file = new File(filePath);