#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#AdditionalJar: androidx.legacy:legacy-support-core-utils ' <<< this is crucial
Sub Process_Globals
Private Storage As ExternalStorage
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Storage.Initialize (Me, "Storage")
End If
Activity.LoadLayout("layout")
End Sub
Sub Button1_Click ' << the only action
Storage.SelectDir(True)
Wait For Storage_ExternalFolderAvailable
Sleep(1000) ' maybe useless
Log(Storage.Root.Name) ' shows correctly the folder previously selected
Dim Name="xxxx.def" As String ' file to read
Dim EZ As ExternalFile
Dim I1,I2 As InputStream
EZ=Storage.FindFile(Storage.Root,Name)
I1=Storage.OpenInputStream(EZ) ' till here OK
Dim EF As ExternalFile ' now the problem
EF.Initialize ' this seems not enough
EF.IsFolder=False
EF.Name=Name
I2=Storage.OpenInputStream(EF) ' Error: java.lang.RuntimeException: Object should first be initialized (JavaObject).
End Sub