Update Android Gallery

2019-09-04 13:46发布

问题:

I am developing an Android app which reads images from external storage for image processing, creates a new folder in "pictures" on external storge and stores the processed images in it.

It takes the standard android gallery a long time or even a reboot to recognize the new folder.

Is there a way to update android gallery programmatically so my new folder gets recognized from gallery?

回答1:

Trigger the mediascanner to read all the media files again. Use this piece of code :

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

This is very inefficient though since it'll begin reading the entire SDCard for changes.



标签: java android adt