Android Question I am puzzled by a comment in the ExternalStorage example

agraham

Expert
Licensed User
Longtime User
In the ExternalStorage example
In the Sub ListView1_ItemClick there is this code fragment with a comment that I cannot see a reason for.
B4X:
Private Sub ListView1_ItemClick (Position As Int, Value As Object)
    Dim f As ExternalFile = Value
    If f = UpItem Then
         '....        
    Else
        'The ExternalFile returned from ListFiles cannot be used directly.
        'We need to first call FindFile.
        f = Storage.FindFile(GetCurrentFolder, f.Name)
        ' ''''
    End If
End Sub
Is/was there a reason for not using the ExternalFile instance from ListFiles as it seems to work fine in my testing so far.
 

agraham

Expert
Licensed User
Longtime User
Something just popped up from the depths of my memory about this. There was a bug in the original ExternalStorage class that I had a hard time convincing Erel was actually there. It resulted in all the ExternalFile instances in ListFiles having their Native fields pointing to the same JavaObject. See post#15 here
Perhaps Erel added the FindFile call to the example to overcome this bug which made the ExternalFile instances in ListFiles unusable and was eventually fixed.
 
Last edited:
Upvote 0
Top