I save an image to the sdcard and it doesn't appear in the Gallery application until I pull off the sdcard and return it back.
Do you have any idea why is it so?
Seems like the Gallery application has some cache that isn't updated on file save...
Actually, I also want to open the just-saved image in Gallery application and have no success with that
this is my question about this issue.
If the SD card files are not showing up in Gallery on your Android phone but appear on your computer, your memory card may have a file system that your mobile is incompatible with. Android doesn't support NTFS file system. Instead, it is fully compatible with FAT32, Ext3, and Ext4 file system.
Delete all .Open Media Rescan app » tick All media checkbox » and hit the Start Media Scan button. Once all media files are rescanned, open the Gallery app. All your media files should be visible on your device now.
If your photos are visible in My Files but are not in the Gallery app, these files may be set as hidden. This prevents Gallery and other apps from scanning for media. To solve this, you can change the option for showing hidden files.
A simpler solution is to use the static convenience method scanFile():
File imageFile = ... MediaScannerConnection.scanFile(this, new String[] { imageFile.getPath() }, new String[] { "image/jpeg" }, null);
where this
is your activity (or whatever context), the mime-type is only necessary if you are using non-standard file extensions and the null
is for the optional callback (which we don't need for such a simple case).
My answer to the original question and to anyone else that may have this problem:
I was having this same problem, images in my app that people saved to the SD card were not showing up in their Gallery immediately. After some searching I found this one line of code inserted after my 'save to sdcard' code that fixed the problem:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
The system scans the SD card when it is mounted to find any new image (and other) files. If you are programmatically adding a file, then you can use this class:
http://developer.android.com/reference/android/media/MediaScannerConnection.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With