I have a SQLite database and get an error when running a certain subroutine.
The error is:
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=963 (# cursors opened by this proc=963)
The code is:
When I have less than ± 900 rows in cursor1, everything works fine, but with a lot of data (looks like more than ± 960 rows) I get the error.
I thought that cur.close and cur2.close would prevent multiple cursors opening and filling the Android allocation, but it seems I still get too many cursors opened.
How can I fix this issue?
The error is:
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=963 (# cursors opened by this proc=963)
The code is:
B4X:
Dim Rows As Int
Dim Data As List
Data.Initialize
Rows = Cursor1.RowCount
'Fill Data
For row = 0 To Rows - 1
Cursor1.Position = row
Dim values(19) As String
Dim cur2 As Cursor
Dim cur As Cursor
cur2 = SQL1.ExecQuery("SELECT * from Ticklist where TickID = "&Cursor1.GetString("TickID"))
cur2.Position = 0
'Bird Name
Tmp = Cursor1.GetString("BirdID") 'BirdID
cur = SQL1.ExecQuery2("SELECT ClemEng, ClemSci from BirdList WHERE BirdID = ?", Array As String(Tmp))
cur.Position = 0
'... fill values() with getstring2 commands...
values(0) = cur.GetString2(0)
'...
values(3) = cur2.GetString2(7)
'... etc
Data.Add(values)
cur.Close
cur2.Close
Next
When I have less than ± 900 rows in cursor1, everything works fine, but with a lot of data (looks like more than ± 960 rows) I get the error.
I thought that cur.close and cur2.close would prevent multiple cursors opening and filling the Android allocation, but it seems I still get too many cursors opened.
How can I fix this issue?