我想删除存储在内部存储的图像。我想出了这个至今:
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();
上一篇:如何更改动作条菜单项的图标编程图标、菜单项、如何更改、动作
下一篇:替代Intent.FLAG_ACTIVITY_CLEAR_TASKIntent、FLAG_ACTIVITY_CLEAR_TASK