目前在做一个应用,需要在应用中保存图片到照片目录 /mnt/sdcsrd/DCIM/Camera ,但是图片保存以后在Gallery 中看不到插入的图片。
搜了很多网站,终于找到解决方法:
插入图片后,运行 Media scanner,更新图片库:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
另外需要在 AndroidManifest.xml 中添加语句:
<intent-filter >
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<data android:scheme="file" />
</intent-filter>
再运行就可以正常更新了。