如何在Andriod中使用绝对路径删除文件

时间:2020-10-05 20:42:12

标签: android file absolute-path

我该如何使用绝对文件路径在android中删除文件,我已按一些建议添加了provider_paths,但该文件在我的toast函数中显示为delete,但未删除该文件,我使用了Providedpath.xml文件进行共享在同一程序中的文件可以正常工作,但是我无法在删除功能中使它在这里工作,这里的代码正在使用

            File photoLcl = new File(String.valueOf(arrayList.get(i).getAbsoluteFile()));
            try {
                Uri imageUriLcl = FileProvider.getUriForFile(activity,
                        activity.getApplicationContext().getPackageName() +
                                ".provider", photoLcl);
                ContentResolver contentResolver = activity.getContentResolver();
                contentResolver.delete(imageUriLcl, null, null);
                Toast.makeText(activity, "File Delete", Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
                e.printStackTrace();
                Toast.makeText(activity, " Error "+e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
            }

0 个答案:

没有答案
相关问题