如何从android中的不同软件包中从外部存储中删除文件?我有这个许可吗?

如何从android中的不同软件包中从外部存储中删除文件?我有这个许可吗?,android,file,Android,File,我想从外部存储器中删除文件,例如路径: String path = "/whatsapp/images/myfile.jpg" 我使用以下代码删除此文件,但不起作用: File file = new File(Environment.getExternalStorageDirectory()+path); public void delete(File file,Context context){ if(file.exists()){ boolean delete

我想从外部存储器中删除文件,例如路径:

String path = "/whatsapp/images/myfile.jpg"
我使用以下代码删除此文件,但不起作用:

File file = new File(Environment.getExternalStorageDirectory()+path);



public void delete(File file,Context context){
    if(file.exists()){
        boolean deleted = file.delete();
        Toast.makeText(context,"File Successfully removed",Toast.LENGTH_SHORT).show();

    }
    else{
        Toast.makeText(context,"File is not here!",Toast.LENGTH_SHORT).show();
    }
}

我还在清单文件中写入必要的权限。

删除文件的实际实现在哪里?请使用Environment.getExternalStorageDirectory().getAbsolutePath()和share logcat