Android尝试查询数据但不返回任何内容

时间:2016-12-05 18:55:19

标签: android sqlite

我正在尝试查询数据。我确认数据正在插入数据库。我尝试将查询转储到日志中,但它没有显示任何内容。它永远不会进入while循环。返回的表中应该总共有4行。

private void queryCol(String t)
{
    Log.d(TAG, "IN queryCol");
    final String     TABLE_NAME = "CInfo";

    String[] projection = {"col1"};

    Cursor cursor = db.query(
            true,
            TABLE_NAME,                               // The table to query
            projection,                               // The columns to return
            null,                                     // The columns for the WHERE clause
            null,                                     // The values for the WHERE clause
            null,                                     // don't group the rows
            null,                                     // don't filter by row groups
            null,                                     // The sort order
            null,
            null
    );

try {
    while (cursor.moveToNext()) {
        Log.d(TAG, "in while");
        String s = DatabaseUtils.dumpCursorToString(cursor);
        cinfo.add(cursor.getString(cursor.getColumnIndex(term)));    //cinfo is an arrayList
        Log.d(TAG, s);
    }
}
catch (Exception e)
{
    Log.d(TAG, "Exception " + e);
}
finally {
    Log.d(TAG, "in finally");
    cursor.close();
    db.close();
}

0 个答案:

没有答案