我正在操作SQLite3我的 Android 应用程序中的数据库。我刚刚从预填充的数据库中读取数据,该数据库有 20 万行和 14 列。条目是文字。所有列的数据类型都是文本。查询最多 11 个字母的单词(例如 ABANDONMENT)效果很好。但对于 12 个或更多(例如放弃),应用程序会崩溃。这是日志猫:
Could not allocate CursorWindow '//data//data//com.example.myapp//databases//database.sqlite' of size 2097152 due to error -12.
threadid=11: thread exiting with uncaught exception (group=0x40adf9f0)
FATAL EXCEPTION: Thread-2883
android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=861 (# cursors opened by this proc=861)
at android.database.CursorWindow.<init>(CursorWindow.java:104)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:162)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:201)
at com.example.myapp.MainActivity.query(MainActivity.java:815)
at com.example.myapp.MainActivity$2.run(MainActivity.java:356)
at java.lang.Thread.run(Thread.java:856)
code:
query = "select * from words where col_1 = \"" + (myWord)+ "\";";
cursor = database.rawQuery(query, null);
if (cursor != null)
cursor.moveToFirst(); // line 815
if (!cursor.isAfterLast()) {
do {
for (i = 1; i < cursor.getColumnCount(); i++) {
temp = cursor.getString(i);
//other stuff
}
} while (cursor.moveToNext());
cursor.close();
}
那么该错误意味着什么以及应用程序崩溃的原因是什么?
错误-12表示游标泄漏。
尝试关闭它:
try {....} finally { cursor.close();}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)