Android Question Export filtered data in B4Xtable

Mostez

Well-Known Member
Licensed User
based on Erel's example, I use this code to export data from B4Xtable in different activities, it works OK, but it exports all data in table even if I applied search criteria in search box. I want to export data in table with or without search criteria.
i think the problem is in this line, but I don't know how to fix it
B4X:
 Dim rs As ResultSet = Table.sql1.ExecQuery("SELECT * FROM data")

B4X:
Public Sub ExportTableToCSV(Table As B4XTable,ExportFileName As String) As ResumableSub
    Try
    Dim data As List
    data.Initialize
    Dim CSVHeaders As List
    CSVHeaders.Initialize
        Dim rs As ResultSet = Table.sql1.ExecQuery("SELECT * FROM data")
    Do While rs.NextRow
        Dim row(Table.Columns.Size) As String
        For i = 0 To Table.Columns.Size - 1
            Dim c As B4XTableColumn = Table.Columns.Get(i)
            row(i) = rs.GetString(c.SQLID)
        Next
        data.Add(row)
        
    Loop
        For i = 0 To Table.Columns.Size - 1
            Dim c As B4XTableColumn = Table.Columns.Get(i)
            CSVHeaders.Add(c.Title)
        Next
    rs.Close
    Dim su As StringUtils
    Dim StorageDir As String = Starter.Provider.SharedFolder
    su.SaveCSV2(StorageDir, ExportFileName, Chr(9), data,CSVHeaders)
        Return True
    Catch
        Log(LastException)
        Return False
    End Try
    
End Sub
 
Top