开发者

Android MediaStore Insert Image Additional file created

I am inserting an Image in the MediaStore cache using the following code snippet:

MediaStore.Images.Media.insertImage(getContentResolver(), selectedFile.getParent() + file.s开发者_开发问答eparator + selectedFile.getName(), selectedFile.getName(),null);

The insertion is ok but it also creates another image thumbnail at the same path. This is not visible in the gallery but when browsed using file browser this image thumbnail is visible. How can I stop this image thumbnail to be created here so as not to confuse the user.


The documentation for MediaStore.Images.Media.insertImage() says that it:

Insert an image and create a thumbnail for it.

What you actually need to do is to access the Media Scanner Service. The service runs by default during startup or after inserting the SD card. You can force it to run using intents but you end up rescanning the entire SD card for a single.

There is, of course, a better solution:

If you're developing for API level 8 or higher (Android 2.2), use the scanFile static function from MediaScannerConnection, documented here.

For API 7 or lower, it's a bit more complicated but you can put everything together with a wrapper best explained in the following post: dynamically add pictures to gallery widget

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜