0

我有时会收到此“sqlite3_close(0x1f7f708)失败:27”错误,我不明白为什么。这是我的代码:

    xMessage[] msgs = new xMessage[howMany];
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor, cursorData = null;

    cursor = db.query(mail_bridge_table_name, new String[] {mbfn_mbridge_PK, mbfn_mdata_FK, mbfn_contacts, mbfn_subject, mbfn_sentTime, mbfn_receivedTime, mbfn_maccount_FK }, null,
              null, null, null, mbfn_sentTime + " desc", first + "," + howMany);

    if (cursor != null)
          cursor.moveToFirst();
    else
    {
        msgs[0] = new xMessage();
        msgs[0].set_bodyPlain("Mail data not found!");
        return msgs;
    }
    long count = cursor.getCount();
    for (int i = 0; i < count; i++)
    {
             [omissis: db unrelated code....]

        cursorData = db.query(mail_data_table_name, new String[] {mdfn_mdata_PK, mdfn_header, mdfn_body }, mdfn_mdata_PK + "=?",
                  new String[]{cursor.getString(mbfi_mdata_FK)}, null, null, null, null);

        if (cursorData != null)
        {
            cursorData.moveToFirst();
        }
        cursor.moveToNext();
    }
    if (cursor != null)
    {
        cursor.close();
    }
    if (cursorData != null)
    {
        cursorData.close();
    }
    db.close();    <----- here I get sometime the error
    return msgs;

我有另一个线程使用同一个数据库,但即使停止它也会出现错误。我环顾四周,在论坛上发现 failed: 27 持续尝试关闭数据库,但某些操作仍处于打开状态......但我只打开了两个我关闭的游标。

有人可以帮忙吗?自两天以来,我一直在解决这个问题..

4

1 回答 1

0

我想这就是答案。sqlite3_close 失败 27 是什么意思?. 这基本上意味着有语句没有调用 close()。

于 2013-04-02T06:48:34.773 回答