Cursor and Adapter

六月ゝ 毕业季﹏ 提交于 2019-11-28 00:28:25

I think your problem is in

try {
    db.rawQuery("SELECT * FROM AC_list", null);
} finally {
    if (db != null)
            Log.i("tag", "db closed");
                db.close();
}

you are closing it as soon as you query and your query is never saved into databaseCursor, maybe what you wanted to do was:

try {
    databaseCursor = db.rawQuery("SELECT * FROM AC_list", null);
} catch(Exception e) {
    if (db != null)
            Log.i("tag", "db closed");
                db.close();

}

I hope this helps

Cursor databaseCursor = null;

This is what you are passing to the adapter. Sure you are querying later, but you are never capturing the cursor result from that query, nor are you setting the cursor on the adapter. So since cursor is always null, you never have results.

Oh, you also need to keep the db open while your cursor is alive. Use the startManagingCursor method on the activity rather than close the database.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!