android - SQLite CursorWindow limit - How to avoid crash -


i have execute query , store result in list, function use follow :

list<spoolindb> getspoolinrecords(string label, boolean getlastinserted) {     list<spoolindb> spoolinlist = new arraylist<>();     try {         if (mdb == null)             mdb = mdbhelper.getwritabledatabase();          sqlitequerybuilder qb = new sqlitequerybuilder();         qb.settables(table_spoolin);          cursor c = qb.query(mdb, null, " label='" + label + "'", null, null, null, " dateins " + (getlastinserted ? "desc" : "asc"));         if (c != null) {             c.movetofirst();             if (c.getcount() > 0) {                 int ndxid = c.getcolumnindex("id");                 int ndxserverid = c.getcolumnindex("serverid");                 int ndxlabel = c.getcolumnindex("label");                 int ndxvalue = c.getcolumnindex("value");                 int ndxpriority = c.getcolumnindex("priority");                 int ndxdateins = c.getcolumnindex("dateins");                  {                     spoolindb spoolin = new spoolindb();                     spoolin.setid(c.getstring(ndxid));                     spoolin.setserverid(c.getstring(ndxserverid));                     spoolin.setlabel(c.getstring(ndxlabel));                     spoolin.setvalue(c.getstring(ndxvalue));                     spoolin.setpriority(c.getstring(ndxpriority));                     spoolin.setdateins(c.getstring(ndxdateins));                     spoolinlist.add(spoolin);                  } while (c.movetonext());             }             c.close();         }     } catch (exception e) {         wil.writefile("4)dbgest - exception: " + e.tostring());     }     return spoolinlist; } 

in normal context function work perfectly, in case function produce exception:

window full: requested allocation 3209815 bytes, free space 2096647 bytes, window size 2097152 bytes 

this problem occour because in "values" field store json datas in case bigger 2mb, can't forecast when data bigger 2mb, need solution work always.

how can solve problem ?

cursorwindow size limit 2mb (as of now). cannot read single row size exceeds 2mb because not possible put in cursor.

so instead of storing entire json single element, can parse , store in separate columns or tables in database.

so that,

  1. you can leave unwanted data in json saving in database.
  2. you can query part of data (few columns) @ time queried data not cross 2mb cursorwindow limit.

or can try out other database systems, realm (i haven't tried it, i'm not sure if there limit there).


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -