Android Question Migrating from SQLite to Mysql (replacing cursors)

Daniel44

Active Member
Licensed User
Hello everyone.
I'm migrating my project from sqlite to mysql. I'm working with OkhttpUtils2 and a php file. In my sqlite project I have some cursors for example
DBCursor = ("SELECT * TABLE1 ORDER BY FIELD1,FIELD2") I don't know if it's right but I'm replacing them for example with maps and lists.

In SQLite:

B4X:
Sub arrangementItems
Dim VARIABLE As String = ""
    For i = 0 To dbCursor.RowCount - 1
        dbCursor.Position = i
        If dbCursor.GetString("X-field") <> HR Then
    VARIABLE = dbCursor.GetString("X-field")
end Sub

In my Mysql project I replace them in this way:
B4X:
Sub arrangeHR
    ProgressDialogShow("Recovering data")
    ExecuteRemoteQuery("SELECT * FROM TABLE1 ORDER BY FIELD1, FIELD2", ARRANGEHR)
End Sub

Sub ExecuteRemoteQuery(Query As String, JobName As String)
    Dim Job As HttpJob
    Job.Initialize(JobName, Me)
    Job.PostString(strURL, Query)
   
End Sub

then in the Jobdone I call them by their Jobname( ARRANGEHR in this case :

B4X:
Sub JobDone (Job As HttpJob)
   ProgressDialogHide
     If Job.Success Then
       Dim res As String
       Dim jobResult As String = Job.GetString
       res = Job.GetString2("UTF8")
Case ARRANGEHR
                Dim organizedlist As List = Json2List(jobResult)
                organizedlist = parser.NextArray
                Dim HR As String = ""
               
        For i = 0 To organizedlist.Size -1
            Dim morganizada As Map
            morganized = organizedlist.Get(i)
           
             If morganized.Get("numerohr")<> HR Then
                 HR = morganized.Get("numerohr")

etc..

My question is if I am doing well replacing sql cursors in mysql with maps and list and then iterate them or if there is another way

Then when I have methods with parameters that also have cursors in sqlite I don't know if to put them inside the case and then in the jobdone or if I can do another jobdone. I know it's a bit confusing and I don't know if I'm explaining myself well. Thank you very much in advance
 
Last edited:

Daniel44

Active Member
Licensed User
Hey Erel I'm not using JRDC2 coz I have not a VPN to use it . I've read somewhere is needed a VPN to use.Thank you!
 
Upvote 0
Top