B4J Code Snippet SQL rowcount

To get the number of rows returned by a query without having to traverse the whole resultset

B4X:
Sub rowCount(rs As JavaObject) As Int
   rs.RunMethodJO("last",Null)
   Dim count As Int = rs.RunMethod("getRow",Null)
   rs.RunMethod("beforeFirst",Null) 
   Return count
End Sub

Use preferably before
B4X:
   do while rs.NextRow

call with
B4X:
   Log(rowCount(c1)) ' c1 is the resultset
 
Top