问题
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.
来源:https://stackoverflow.com/questions/17156746/update-android-gallery