Android平台下如何删除SDCARD中的文件/文件夹?
我想知道如何删除 SD 卡中的文件/文件夹。我尝试了下面的代码:
File folder = Environment.getExternalStorageDirectory();
String fileName = folder.getPath() + "/LOST.DIR/ppt52.ppt";
File myFile = new File(fileName);
if(myFile.exists()) {
myFile.delete();
}
但它不起作用。
I want to know how to delete a file/folder in SD Card. I tried the code below:
File folder = Environment.getExternalStorageDirectory();
String fileName = folder.getPath() + "/LOST.DIR/ppt52.ppt";
File myFile = new File(fileName);
if(myFile.exists()) {
myFile.delete();
}
but it didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您尝试访问的文件夹已受保护。所以在访问之前尝试改变访问模式。
或者您缺少以下权限,
Maybe the folder you are trying to access is Protected. So try to change the access mode before accessing it.
Or you are missing the following permission,