我使用簡單的sql lite查詢從表中獲取計數值。SQLite Count where query
Cursor cursor = db.rawQuery("SELECT sum(name2) FROM " + TABLE_NAME, null);
if (cursor.moveToFirst()) {
return cursor.getInt(0);
}
return cursor.getInt(0);
這工作好
但是當我添加一個where子句選擇查詢
Cursor cursor = db.rawQuery("SELECT sum(name2) FROM " + TABLE_NAME + "WHERE name in (" + k + ")", null);
if(cursor.moveToFirst()) {
return cursor.getInt(0);
}
return cursor.getInt(0);
進程意外停止.......
認真地,格式化您的代碼。 –
另外,請從'logcat'發佈堆棧跟蹤。 –