我创建了临时文件夹以在Android N中存储完整尺寸的图像。如何删除图像?此代码不适用于我的程序。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (ContextCompat.checkSelfPermission(NewIssueActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
File file = new File(mHighQualityImageUri.getPath());
Log.d("PostDeleteImage", "+++" + mHighQualityImageUri.getPath());
file.delete();
Log.d("PostDeleteImage", "+++");
if (file.exists()) {
try {
Log.d("PostDeleteImage", "+++===");
file.getCanonicalFile().delete();
Log.d("PostDeleteImage", "+++---");
} catch (IOException e) {
e.printStackTrace();
}
Log.d("PostDeleteImage", "===");
if (file.exists()) {
getApplicationContext().deleteFile(file.getName());
Log.d("PostDeleteImage", "----------" + file.getName());
}
}
}
}