Android Question Get List of File paths into an array using WildCards

rasoul_ghasemiyan

New Member
Hi,
I used this class wildcardlisting to get the file path that written by DonManfred
His class get list of files on phone and display them with the Log function.
How can I save the path of found files in an array or a string?
For example, I use this:

B4X::
Sub Process_Globals
    Dim str As String
    Dim lst As List
End Sub

Sub Service_Create
    lst.Initialize
End Sub

Sub wcl_ListFilesFinish(FileListing As List)
    Log("wcl_ListFilesFinish("&FileListing.Size&")")
    For i = 0 To FileListing.Size -1
        Log(FileListing.Get(i))
        
        str = str & FileListing.Get(i) & CRLF
'       OR
        lst.Add(FileListing.Get(i))
    Next
End Sub

Sub Display
    For Each i As String In lst
        Log(i)
    Next
    Log(str)
End Sub
But str and lst don't contain path of found files. ☹
any answer will be appreciated.
 

DonManfred

Expert
Licensed User
Longtime User
But str and lst don't contain path of found files. ☹
any answer will be appreciated.
i don´t see you running any search.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim wcl As wildcardlisting
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    wcl.Initialize(Me,"WCL")
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_Permissionresult(Permission As String, Result As Boolean)
    If Result Then
        wcl.ListFiles(File.DirRootExternal,True,"*.*",True,True)
    End If
    
End Sub
Sub WCL_ListFilesFinish(FileListing As List)
    Log("wcl_ListFilesFinish("&FileListing.Size&")")
    For i = 0 To FileListing.Size -1
        Log(FileListing.Get(i))
    Next
End Sub
 

Attachments

  • WCLEx.zip
    10.1 KB · Views: 253
Upvote 0

rasoul_ghasemiyan

New Member
i don´t see you running any search.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim wcl As wildcardlisting
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    wcl.Initialize(Me,"WCL")
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_Permissionresult(Permission As String, Result As Boolean)
    If Result Then
        wcl.ListFiles(File.DirRootExternal,True,"*.*",True,True)
    End If
   
End Sub
Sub WCL_ListFilesFinish(FileListing As List)
    Log("wcl_ListFilesFinish("&FileListing.Size&")")
    For i = 0 To FileListing.Size -1
        Log(FileListing.Get(i))
    Next
End Sub
Hi DonManfred, apologize
So thank you
It works properly now😍
 
Upvote 0
Top