如何删除SD卡上的文件? [英] How to delete a file from SD card?
问题描述
我创建一个文件作为附件发送到电子邮件。现在我要发送电子邮件后删除图像。有没有一种方法来删除文件?
我已经试过 myFile.delete();
,但它并没有删除文件
我用这个code为Android,所以编程语言是使用Java常用的Android方式访问SD卡。我删除了 onActivityResult
的方法,该文件时的意图
发送邮件后,返回到屏幕上。
档案文件=新的文件(selectedFilePath);
布尔删除= file.delete();
在这里selectedFilePath是文件中要删除的路径 - 例如:
/sdcard/YourCustomDirectory/ExampleFile.mp3
I am creating a file to send as an attachment to an email. Now I want to delete the image after sending the email. Is there a way to delete the file?
I have tried myFile.delete();
but it didn't delete the file.
I'm using this code for Android, so the programming language is Java using the usual Android ways to access the SD card. I am deleting the file in the onActivityResult
method, when an Intent
is returned to the screen after sending an email.
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
这篇关于如何删除SD卡上的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!