本文介绍了删除内部存储文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除存储在内部存储的图像。我想出了这个至今:

I'm trying to delete images stored in internal storage. I've come up with this so far:

File dir = getFilesDir();
File file = new File(dir, id+".jpg");
boolean deleted = file.delete();

这是另外一个问题,这是回答:

File dir = getFilesDir();
File file = new File(dir, "my_filename");
boolean deleted = file.delete();

我的例子总是返回false。我可以看到日食 FX 2930.jpg DDMS中的文件。

My example always returns false. I can see the file fx 2930.jpg in DDMS in eclipse.

推荐答案

getFilesDir()不知何故没有工作。使用方法,该方法返回整个路径和文件名,得到所希望的结果。这里是code:

The getFilesDir() somehow didn't work.Using a method, which returns the entire path and filename gave the desired result. Here is the code:

File file = new File(ih.getImgPath(id));
boolean deleted = file.delete();

这篇关于删除内部存储文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 14:12