从URI中删除图像,存储图像的完整大小

时间:2017-08-07 08:06:27

标签: android

我创建了临时文件夹以在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());
                        }
                    }
                }
            }

0 个答案:

没有答案