Android Question Cursor as Parameter

Rob Bliss

Member
Licensed User
Longtime User
When passing a cursor as a parameter, when is the correct time(s) to close the cursor?

B4X:
Sub main
    Dim v_Cursor as Cursor = SQL.ExecQuery("SELECT * FROM TABLE")
    func(v_Cursor)
    v_Cursor.Close   '?
End Sub

Sub func(p_Cursor as Cursor)
    p_Cursor.getString("column")
    p_Cursor.Close   '?
End Sub

Cheers
 

MarkusR

Well-Known Member
Licensed User
Longtime User
i would close it where u open it, in the same sub. its easier to understand.

just think about if you need this.
if u would close it in "func" u can't use "func" again.
B4X:
Sub main
    Dim v_Cursor as Cursor = SQL.ExecQuery("SELECT * FROM TABLE")
    func(v_Cursor)
    func(v_Cursor)
    v_Cursor.Close
End Sub
 
Last edited:
Upvote 0
Top