我正试图通过此代码在SD卡上创建私人目录,
if(Util.isExternalStorageWritable()) {
int writePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int readPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
if (writePermission == PackageManager.PERMISSION_GRANTED && readPermission == PackageManager.PERMISSION_GRANTED) {
File folder = new File(AddWazaif.this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "directory");
if (!folder.exists()) {
folder.mkdirs();
}
}
}
但未创建目录。仅使用此方法Environment.getExternalStorageDirectory()
创建的目录。但我想只有私人目录所以当应用程序去卸载目录也被删除。请帮忙。
清单:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />