Android中如何删除SD卡中存在的文件?
我尝试使用这些代码从 android 中删除 sd 卡中的 wav 文件
File file = new File("/sdcard/AutoInsurance_Toolkit/AudioRecorder/1311531953080.wav");
boolean deleted = file.delete();
,并且在清单中使用了权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
请告诉我我是否在这里丢失了某些内容,因为每次代码成功执行但没有删除 SD 卡中的内容?
I tried these codes to delete a wav file in the sd card from android
File file = new File("/sdcard/AutoInsurance_Toolkit/AudioRecorder/1311531953080.wav");
boolean deleted = file.delete();
and also in the manifest used the permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
Please tell me am I missing something here because each time the code gets executed successfully but not deleting the content in SD card?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您具有 WRITE_EXTERNAL 权限、路径正确且文件权限为 WORLD_WRITABLE,您的代码将正常工作。我敢打赌该文件不是以全局可写的方式创建的,因此除非您的软件创建了该文件,否则您将无法删除它。
Your code will work assuming you have the WRITE_EXTERNAL permission, the path is correct and the file permission is WORLD_WRITABLE. I'm betting the file was not created as world writable so unless your software created the file you won't be able to delete it.