在使用SQLiteDatabase插入一个比较大的数据时,抛出如下异常:
W/CursorWindow: Window is full: requested allocation 1354087 bytes, free space 141032 bytes, window size 2097152 bytes
如下图所示:
这是因为:
Android SQLite在光标返回行的窗口是指定了一个最大大小为2MB的config_cursorWindowSize值,如果你的行大小超过此限制,你会得到这个错误。无论如何,在SQLite数据库存储大量的数据是不是一个好主意,应在数据库中放置文件系统和存储文件的路径。
【Android SQLite returns rows in cursor windows that have the maximum size of 2MB as specified by config_cursorWindowSize. If your row exceeds this limit, you’ll get this error.
Storing large data in sqlite database is not a good idea anyway. Store files in filesystem and paths in database.】
在Android源码中config_cursorWindowSize值定义如下:
sdk\platforms\android-23\data\res\values\configs.xml:
<!-- When a database query is executed, the results retuned are paginated in pages of size (in KB) indicated by this value -->
<integer name="config_cursorWindowSize">2048</integer>