Android的:如何从外部存储中删除的文件? [英] Android: How to remove files from External storage?
问题描述
我实现它生成一个应用程序,并创造外部存储器中的文件。你们可以帮我怎么才能删除?
感谢您, 钱德拉
修改-1:我添加以下code,仍然我收到了同样的问题,请看看我下面的code,
字符串FULLPATH =到/ mnt / SD卡/;
的System.out.println(完整路径);
尝试
{
档案文件=新的文件(FULLPATH,audio.mp3);
如果(file.exists())
{
布尔结果= file.delete();
的System.out.println(应用程序能够删除的文件,结果是:+结果);
// file.delete();
}
其他
{
的System.out.println(应用程序不能够删除的文件);
}
}
赶上(例外五)
{
Log.e(应用程序,异常而删除的文件+ e.getMessage());
}
在LogCat中我得到的应用程序能够删除的文件,结果是:假。我连着执行此之后,我的屏幕截图。请看看成。并建议我。
档案文件=新的文件(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
这篇关于Android的:如何从外部存储中删除的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!