Do'nt like to loop over the records trying to find a more direct way.
Instead of using a List, we can also use Map. No loop is used when "finding" the record.
[CODE lang="b4x" highlight="5,18,25"]Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SQL1 As SQL
Private Result As Map
End Sub
Public Sub Initialize
Result.Initialize
SQL1.Initialize(File.DirInternal, "data.sqlite", False)
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Dim RS As ResultSet = SQL1.ExecQuery("SELECT id, name, age FROM data")
Do While RS.NextRow
Result.Put(RS.GetInt("id"), CreateMap("name": RS.GetString("name"), "age": RS.GetInt("age")))
Loop
RS.Close
End Sub
Private Sub BtnFind_Click
Dim id As Int = 2
Dim record As Map = Result.Get(id)
Dim name As String = record.Get("name")
Dim age As Int = record.Get("age")
Log($"${name} is ${age} years old"$)
End Sub[/CODE]