Android Question For / next cycle with JobDone

Status
Not open for further replies.

marcos

Member
Licensed User
Longtime 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
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

marcos

Member
Licensed User
Longtime 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 :-(
 
Upvote 0

OliverA

Expert
Licensed User
Longtime 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.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

marcos

Member
Licensed User
Longtime 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 :-(
 
Upvote 0
Status
Not open for further replies.
Top