我正在尝试从数据库中获取数据,我的数据库包含UTF8字符,当我这样做时,我得到“SQLite3.Exception:数据库磁盘映像格式错误”。
以下是代码:
public ArrayList<String> getDefinations(String query, int column_index)
{
ArrayList<String> words = new ArrayList<String>();
MatrixCursor mcursor = null;
try {
Stmt stmt = getDB2().prepare(query);
if (stmt.step()) {
stmt.get_cursor().moveToFirst();
mcursor = stmt.get_cursor();
try {
mcursor.moveToFirst();
do {
words.add(mcursor.getString(column_index));
} while (mcursor.moveToNext());
} catch (IndexOutOfBoundsException e) {
if (MainActivity.logcat_status) {
Log.e("Error", e + "");
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
if (MainActivity.logcat_status) {
Log.e("Error", e + "");
}
}
这是我正在使用的查询
select pos, definition, sample FROM word INNER JOIN sense ON word.wordid = sense.wordid
INNER JOIN synset ON sense.synsetid = synset.synsetid LEFT JOIN sample ON
sample.synsetid = synset.synsetid WHERE lemma = 'life'
这是我在日志中得到的
01-29 11:04:19.532: E/Error(2023): SQLite3.Exception: database disk image is malformed
01-29 11:04:19.544: E/dalvikvm(2023): JNI ERROR (app bug): accessed stale local reference
0x7f00001d (index 7 in a table of size 7)
01-29 11:04:19.544: E/dalvikvm(2023): VM aborting
01-29 11:04:19.544: A/libc(2023): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1),
thread 2023 (abdkosh.android)