After you have your new image file on the sdcard you need to use a MediaScannerConnection to make it known to the Gallery. The method is scanFile. It's best for your activity to implement the MediaScannerConnectionClient interface, and the two callbacks to coordinate the addition of your new image file.
- dave On Dec 26, 10:50 pm, Mike M <[email protected]> wrote: > Hey all, > > I am saving an image taken by the camera to a unique folder on the > sdcard. The image saves fine, but I cannot view it in the Gallery. I > can see it in the file system, but I cannot view the image in the > Gallery app until I reboot the phone or mount the sdcard, and then > umount. > > Here's the code: > > public static void saveImageToCard (Bitmap bm, String title, > String description, Context context) { > > //replace and append the title with the correct extension > title = title.replace(" ", "_") + ".jpg"; > > File Directory = new File(Environment.getExternalStorageDirectory > () + "/myFolder"); > File file = new File(Directory.getAbsoluteFile() + "/" + > title); > > if (!Directory.exists()) { > Directory.mkdirs(); > } > > try { > FileOutputStream fos = new FileOutputStream(file); > bm.compress(Bitmap.CompressFormat.JPEG, 100, fos); > fos.close(); > } catch (IOException e) { > e.printStackTrace(); > } > > } > > As I said, the file is saved fine, I can see it in the FS, and I can > view it after the card has been umounted/mounted or rebooted. Is it > an issue that I'm not correctly closing the file?? I don't think > that's it, but I'm not sure why I can't view the image. I believe I > tried saving the file using getContentResolver().insert() and didn't > have this issue, but I want to save the images to a specific folder > that I create. > > Any ideas? > > Thanks in advance, > > Mike -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

