If you look up the source of CursorWindowAllocationException
it reads:
This exception is thrown when a CursorWindow couldn't be allocated,
most probably due to memory not being available.
If you follow the stack, you'll see that the call com.j256.ormlite.android.AndroidDatabaseConnection.queryForLong
is creating a cursor for every createOrUpdate
call.
So what's likely happening here is that there are too many Cursors
being created before the memory is freed.
You should execute these calls in a transaction, or better yet, use batch tasks. E.g.
actionDao.callBatchTasks(new Callable<Void>() {
public Void call() throws SQLException {
for (Action action : actionList) {
actionDao.createOrUpdate(action);
}
return null;
}
});
createOrUpdate();
and all other logic runs inside orm library. Well how I can see no one knows why ormlite fails. – Liriodendron