【发布时间】:2012-04-03 13:33:14
【问题描述】:
我用这种方式将一些图片保存在 SD 卡上:
File dir = new File(fullPath);
if (!dir.exists()) {
dir.mkdirs();
}
String id = Integer.toString(i+1);
OutputStream fOut = null;
File file = new File(fullPath, id);
file.createNewFile();
fOut = new FileOutputStream(file);
// 100 means no compression, the lower you go, the stronger the compression
bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(this.getContentResolver(), file.getAbsolutePath(), file.getName(), file.getName());
但是,当我从 SD 卡中删除这些图像时,它们会保留在图库中。
File path = new File(path);
File[] lstFile;
if(path.exists()){
lstFile = path.listFiles();
for(int i =0; i<lstFile.length;i++){
File file = lstFile[i];
file.delete();
}
path.delete();
}
这些图片怎么会留在图库中,我该如何删除它们?有没有办法一开始就避免将这些图像保存在图库中?
【问题讨论】:
-
MediaStore 创建的缩略图是什么。难道它不是你删除文件的“记忆”所在的地方吗?
标签: android image sd-card image-gallery delete-file