Android Question What folders can be shown in Gallery?

josejad

Expert
Licensed User
Longtime 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:
/storage/emulated/0/Android/data/com.semi.bqa/files/checklist/2900040_U09/

I've tried this code to show the images in the gallery.
https://www.b4x.com/android/forum/threads/show-image-in-gallery-android-7-0.97662/#post-615939

If I pass the pictures in that folder, for example:
B4X:
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)
       Phone.SendBroadcastIntent(i)
   Else
       Dim ctxt As JavaObject
       ctxt.InitializeContext
       Dim MediaScannerConnection As JavaObject
       MediaScannerConnection.InitializeStatic("android.media.MediaScannerConnection")
       Dim interface As Object = MediaScannerConnection.CreateEventFromUI("android.media.MediaScannerConnection.OnScanCompletedListener", "ScanCompleted", _
           Null)
       MediaScannerConnection.RunMethod("scanFile", Array(ctxt, Array As String(FilePath), Array As String("image/jpeg"), interface))
   End If

End Sub

It shows in the log:
B4X:
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
B4X:
Dim FilePath As String = File.Combine(File.DirRootExternal, "Pictures/" & Image)
I get in log:
B4X:
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
 
Top