3

do you know how to create a folder in which photos will be saved and os and other apps should see that folder as photo album? I need to save photos in a certain album and if album does not exists, I need to create it.

Thanks

Buda Gavril
  • 21,409
  • 40
  • 127
  • 196

1 Answers1

3

If you store images files anywhere on the external storage (with the exception of locations that also contain a .nomedia file), the media scanner, and thus the built-in "Gallery" app, will locate them and display them.

To be a good citizen you should place such files in the recommended location on the external storage using getExternalStoragePublicDirectory. You can pass that DIRECTORY_PICTURES for images.

Be advised though, that stuff is only available as of API level 8. If you need to also support earlier API versions you can use getExternalStorageDirectory and still use the correct recommended path on your own.

And, as always, you need to make sure the external storage is available before you try to write to it.

Charlie Collins
  • 8,806
  • 4
  • 32
  • 41
  • it seems to work, but when I take some photos and save them in that folder, I can't see then until I restart my device. Is a way to notify the os that I've savem some photos in that folder? – Buda Gavril Feb 08 '11 at 08:01
  • Yes, any time you want to you can kick off the "media scanner." Programatically you can use the MediaScannerConnection: http://stackoverflow.com/questions/4646913/android-how-to-use-mediascannerconnection-scanfile. It always gets restarted when you reboot, so that's why it works then. (You can also find the "Media Storage" app under Settings->Applications and "Clear data," but that may clear more than you want, like ringtones, album covers, etc.) – Charlie Collins Feb 08 '11 at 14:55