Android Question Folders and Files are not showing in windows explorer

Marlou Fin

Member
Licensed User
Hi Guys,

I have this application that export sql data to csv using stringUtils. I successfully exported the data to the csv file format using DirDefaultExternal and also DirRootExternal as the directory. The problem now, I can see the file and folder in the device but I cannot find it when exploring it in windows.

Please advise


Thanks,
Marlou
 

Marlou Fin

Member
Licensed User
I tried to reboot the device and now the folder and the files are already showing in the windows explorer. Any idea why it not showing instantly the file created with out rebooting the device?
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
I tried to reboot the device and now the folder and the files are already showing in the windows explorer. Any idea why it not showing instantly the file created with out rebooting the device?
Search for MediaScanner in the forum.
 
Upvote 0

Marlou Fin

Member
Licensed User
Thanks for saving Johan, this really big help. I used this sub and then it showing now instantly the files that are exported in the window explorer.

Sub ForceGallery (Dir As String, FileName As String)
Dim Phone As Phone
If Phone.SdkVersion<19 Then
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_MOUNTED", "file://" & File.Combine(Dir, FileName))
Phone.SendBroadcastIntent(i)
Else
Dim context As JavaObject
context = context.InitializeStatic("anywheresoftware.b4a.BA").GetField("applicationContext")
Dim paths() As String = Array As String(File.Combine(Dir,FileName)) 'files to scan
Dim mediaScanner As JavaObject
mediaScanner.InitializeStatic("android.media.MediaScannerConnection")
mediaScanner.RunMethod("scanFile", Array As Object(context, paths, Null, Null))
End If
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…