Android Question keyvaluestore problem

tufanv

Expert
Licensed User
Longtime User
Hello

I am using kvs (not v2 ) . I am getting an error of :

android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=406 (# cursors opened by this proc=406)

full msg is here :
B4X:
Error occurred on line: 81 (KeyValueStore)
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=406 (# cursors opened by this proc=406)
    at android.database.CursorWindow.<init>(CursorWindow.java:108)
    at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
    at android.database.sqlite.SQLiteCursor.clearOrCreateWindow(SQLiteCursor.java:316)
    at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:142)
    at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:136)
    at anywheresoftware.b4a.sql.SQL$CursorWrapper.getRowCount(SQL.java:313)
    at ct.livefx.keyvaluestore._listkeys(keyvaluestore.java:87)
    at ct.livefx.main._jobdone(main.java:1384)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5938)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 

DonManfred

Expert
Licensed User
Longtime User
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
The result of the database-query is more than 2mb of data. 2mb is the limit of sqlite for one query.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
The result of the database-query is more than 2mb of data. 2mb is the limit of sqlite for one query.
I fixed it with changing the public sub listkeys of datastore module to

B4X:
Public Sub ListKeys As List
    Dim c As Cursor
    c = sql1.ExecQuery("SELECT key FROM main")
    Dim res As List
    res.Initialize
    For row = 0 To c.RowCount - 1
        c.Position = row
        res.Add(c.GetString2(0))
    Next
    c.Close
    Return res
   
End Sub

added a c.close.
 
Upvote 0
Top