由网友(久伴我)分享简介:我通过插入图像:ContentValues values = new ContentValues(); values.put(Images.Media.TITLE, filename);values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());...
我通过插入图像:
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, filename);
values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "image/jpeg");
Uri uri = this.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
但是,当我试图删除
But when I try to delete
File f = new File(imageURI);
f.delete();
图片不再存在,但空的占位符。任何想法?
The picture is no longer there but an empty placeholder is. Any ideas?
推荐答案
Android有各种各样的缓存,它跟踪的媒体文件。
Android has a cache of sorts that keeps track of media files.
试试这个:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
这使得MediaScanner服务运行一次,这应该从设备的缓存中删除的删除的图像。
It makes the MediaScanner service run again, which should remove the deleted image from the device's cache.
看来你还需要这个权限添加到您的AndroidManifest.xml:
Looks like you also need to add this permission to your AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<data android:scheme="file" />
</intent-filter>
相关推荐
最新文章