My app writes various log files (zipped and text). I can see them on the device using the device file manager. I would like to see them when I connect the device to the PC.
For a different app where I wanted to expose media, I used the following:
When I run this code for the text/zip files, the files are visible from the PC but they show a 0 byte length. When I copy them to the PC, they are still 0 bytes. When lloking at them on the device using the the device file manager, they are the correct size.
Question: Is there a equivalent scan method to expose non-media files to a USB connected PC?
Edit: An added note is that I'm trying to expose the file that is located on the SDCard. I create the file on internal storage and then copy it to the SDCard using the Storage class. Running the above code on the internal file exposes it with the correct size, etc. The SDCard file is the one I can't see correctly.
For a different app where I wanted to expose media, I used the following:
B4X:
' Force the scan of the passed file so it is visible to a USB connected PC.
Public Sub ExposeToPC(Directory As String, FileName As String) As Object
Dim context As JavaObject
context = context.InitializeStatic("anywheresoftware.b4a.BA").GetField("applicationContext")
Dim paths() As String = Array As String(File.Combine(Directory, FileName))
Dim mediaScanner As JavaObject
mediaScanner.InitializeStatic("android.media.MediaScannerConnection")
Return mediaScanner.RunMethod("scanFile", Array As Object(context, paths, Null, Null))
End Sub
When I run this code for the text/zip files, the files are visible from the PC but they show a 0 byte length. When I copy them to the PC, they are still 0 bytes. When lloking at them on the device using the the device file manager, they are the correct size.
Question: Is there a equivalent scan method to expose non-media files to a USB connected PC?
Edit: An added note is that I'm trying to expose the file that is located on the SDCard. I create the file on internal storage and then copy it to the SDCard using the Storage class. Running the above code on the internal file exposes it with the correct size, etc. The SDCard file is the one I can't see correctly.
Last edited: