I am using the room database in my application. I have a feature to download some content within my application. When each content is saved in my DB, I need to update a table that has columns that indicate whether each content is saved or not. We set a boolean in the table when content is saved.
So the flow is: Call an API, save its contents, and after saving update column in another table to true. This happens for multiple APIs. Each content save success will have the update query executed in another table. All API calls are called sequentially.
I am getting the following error for the DAO.
Caused by android.database.CursorWindowAllocationException Cursor window allocation of 2048 kb failed. # Open Cursors=321 (# cursors opened by this proc=321)
When each content is saved, code flow is as follows:
myDao.updateStatus(id) //updates a column value to true
.subscribeOn(Schedulers.io())
.subscribe {
myDao.getContent(id) //Select query to check id is present in table or not
.subscribeOn(Schedulers.newThread())
.subscribe { count ->
if (count > 0) {
//Call next API
}
}
}
The DAO is just updating a small content and selecting a single row that has only a few boolean columns. So, this doesn't come up to 2MB. Then why is this exception occurring in this DAO?