Android Question For / next cycle with JobDone

Status
Not open for further replies.

marcos

Member
Licensed User
I need to retrieve the records from a db sqlite and pass them to a web service through job.PostString.
only the last record is passed to the web service, also If cursor1.RowCount> 0. where am I wrong? how can i pass all the records?

B4X:
Job.Initialize("Job", Me)

    cursor = SQL1.ExecQuery("SELECT * FROM nome")
                      
    If cursor.RowCount > 0 Then
        For i = 0 To cursor.RowCount - 1
            cursor.Position = i
          
       Job.PostString(WS,"nome="&cursor.GetString("nome")&" ")
    Next
 

marcos

Member
Licensed User
Sorry it's perfect for sdkVersion <17, but with Android 9 it always goes wrong.
B4X:
If cursor1.RowCount > 0 Then
        For i = 0 To cursor1.RowCount - 1
            cursor1.Position = i

                j.Initialize("", Me)
                    j.PostString(WS,"a="&cursor1.GetString("name")&"")
                Wait For (j) JobDone(j As HttpJob)
                Log(j.GetString)
                            If j.Success = True Then
                
                Msgbox("ok")
            End If
            j.Release
        Next
mistake :
Log(j.GetString) = java.io.FileNotFoundException: /data/user/0/xxxxxxxxxxxxxx/cache/1 (No such file or directory).


what can it be ? the data in cursor1.GetString ("name") is present :-(
 

OliverA

Expert
Licensed User
You’re logging j.GetString before testing if j.Success is true. If j.Success happens to be false, j.GetString will have no content and throw this error. Also you are not logging j.ErrorMessage in case j.Success is false, so it’s hard to tell what is going on.
 

Computersmith64

Well-Known Member
Licensed User
B4X:
If j.Success = True Then
    Msgbox("ok")
End If
Don't use Msgbox for logging. Use Log("ok") instead & you won't interrupt your loop.

- Colin.
 

marcos

Member
Licensed User
ok. I ran Log( j.ErrorMessage) is receive error : javax.net.ssl.SSLHandshakeException: Connection closed by peer...... for sdk version 28, while it is ok for sdk version 23 why ? help me :-(
 

Erel

Administrator
Staff member
Licensed User
ok. I ran Log( j.ErrorMessage) is receive error : javax.net.ssl.SSLHandshakeException: Connection closed by peer...... for sdk version 28, while it is ok for sdk version 23 why ?
Please start a new thread for this and make sure to post the full error message from the logs.
 
Status
Not open for further replies.
Top