安卓删除从内部存储的文件 [英] android deleting a file from internal storage
本文介绍了安卓删除从内部存储的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建从活动存储在内部存储的文件。我怎样才能删除另一个活动这个文件?
I have created a file stored on internal storage from an activity. How can I delete this file from another activity?
我想我得把该文件的目录(我不知道如何),并删除它。我试图用
I'm thinking I'll have to get the file's directory (which I'm not sure how to) and delete it. I tried using
context.deleteFile();
但它不会工作,因为我试图从非静态方法调用它。
but it won't work because I'm trying to call it from a non-static method.
任何帮助是AP preciated。
Any help is appreciated.
推荐答案
下面是你的答案:
File dir = getFilesDir();
File file = new File(dir, "my_filename");
boolean deleted = file.delete();
这篇关于安卓删除从内部存储的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文