You can add a handler to the server that returns all users and call it with OkHttpUtils2.
Add this code to the DB module:
B4X:
Public Sub GetAllUsers As List
Dim users As List
users.Initialize
Dim rs As ResultSet = sql.ExecQuery("SELECT user FROM data")
Do While rs.NextRow
users.Add(rs.GetString("user"))
Loop
rs.Close
Return users
End Sub
Create a new standard handler class named GetAllUsers with this code:
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim ser As B4XSerializator
Dim bytes() As Byte = ser.ConvertObjectToBytes(DB.GetAllUsers)
resp.OutputStream.WriteBytes(bytes, 0, bytes.Length)
End Sub
Dim job As HttpJob
job.Initialize("", Me)
job.Download(ServerUrl & "/getallusers")
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Dim ser As B4XSerializator
Dim users As List = ser.ConvertBytesToObject(Bit.InputStreamToBytes(job.GetInputStream))
Log(user)
End If
job.Release