Files with an extension for example. "Db" in a list view list

jmich

Member
Licensed User
Longtime User
Hi people,

db files like for example with an extension *. in a
ListView list.

My current code

Dim file1 As String

B4X:
Dim fileList As List
   Dim n As Int

   fileList = File.ListFiles (File.DirAssets)
   fileList.Sort (True)

   For n = 0 To fileList.Size-1
     file1 = fileList.Get (s)
ListView1.AddSingleLine (file1)
   Next
[/ CODE]

The code works - but of course there are all
Files in the list shown.

How can I now only files with the extension *. Db list?
fileList = File.ListFiles (File.DirAssets ". db") returns an error message!

For help, I would be delighted - Thank you

Greeting Jmich
 

Mahares

Expert
Licensed User
Longtime User
Will the below code snippet work for you? I have tested it.
B4X:
    Dim fileList As List
      Dim n As Int
      Dim file1 As String
      Dim ListView1 As ListView
      ListView1.Initialize("ListView1")
      fileList = File.ListFiles (File.DirAssets)
      fileList.Sort (True)
    
      For n = 0 To fileList.Size-1
           file1 = fileList.Get (n)
           If file1.EndsWith(".db") Then
              ListView1.AddSingleLine (file1)
           End If
      Next
 
Upvote 0
Top