Android MediaStore Insert Image Additional file created

◇◆丶佛笑我妖孽 提交于 2019-12-05 21:18:00
Mircea Nistor

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!