Android Question What folders can be shown in Gallery?

José J. Aguilar

Licensed User
Hi everyone:

My app make pictures and store them in the safe folder GetSafeDirDefaultExternal("checklist")
I created a folder insided "checklist" folder for every site I make folders. Example, site 2900040_U09 store the pictures in:

I've tried this code to show the images in the gallery.

If I pass the pictures in that folder, for example:
Sub ShowInGallery (Image As String)
   Dim dir As String= rp.GetSafeDirDefaultExternal("checklist") & "/2900040_U09"
   Dim FilePath As String = File.Combine(dir, Image)
   Dim Phone As Phone
   If Phone.SdkVersion <= 18 Then           ' min - 4.3.1
       Dim i As Intent
       i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & FilePath)
       Dim ctxt As JavaObject
       Dim MediaScannerConnection As JavaObject
       Dim interface As Object = MediaScannerConnection.CreateEventFromUI("", "ScanCompleted", _
       MediaScannerConnection.RunMethod("scanFile", Array(ctxt, Array As String(FilePath), Array As String("image/jpeg"), interface))
   End If

End Sub

It shows in the log:
Scan Completed: /storage/emulated/0/Android/data/com.semi.bqa/files/checklist/2900040_U09/1.8(2).jpg
Scan Completed: content://media/external/file/21731

But I can't see the picture in the gallery.
But if I copy the picture to "Picture" folder
Dim FilePath As String = File.Combine(File.DirRootExternal, "Pictures/" & Image)
I get in log:
Scan Completed: /storage/emulated/0/Pictures/1.16(2).jpg
Scan Completed: content://media/external/images/media/21737
Now the image is shown in Gallery.

Must be then copied (or directly saved) in "Pictures" folder?
I'd like to show them from the folder I got them now, or I'll have to move all the folders in the next app update in order to show them in gallery.

Thanks in advance