更新时间:2023-11-22 21:35:10
档案文件=新的文件(selectedFilePath);
布尔删除= file.delete();
在这里selectedFilePath是文件中要删除的路径 - 例如:
/sdcard/YourCustomDirectory/ExampleFile.mp3
I implementing an application which generates and create files in External storage. Can you guys help me how can we remove that?
Thank you, Chandra
Edit-1: I added following code and still I am getting the same problem, Please have a look at my code below,
String fullPath = "/mnt/sdcard/";
System.out.println(fullPath);
try
{
File file = new File(fullPath, "audio.mp3");
if(file.exists())
{
boolean result = file.delete();
System.out.println("Application able to delete the file and result is: " + result);
// file.delete();
}
else
{
System.out.println("Application doesn't able to delete the file");
}
}
catch (Exception e)
{
Log.e("App", "Exception while deleting file " + e.getMessage());
}
In the LogCat I am getting Application able to delete the file and result is:false. I attached my screen shot after executing this. Please have a look into that. And suggest me.
File file = new File(selectedFilePath);
boolean deleted = file.delete();
where selectedFilePath is the path of the file you want to delete - for example:
/sdcard/YourCustomDirectory/ExampleFile.mp3