以下语句
cursor.moveToNext()
总是为false。我期望该循环执行一次。 我已经测试过查询实际上返回数据,有人知道问题出在哪里吗? String query ="SELECT(SELECT COUNT(*) FROM Table1) as count1, (SELECT COUNT(*) FROM Table2) as count2;";
Cursor mCursor = mDb.rawQuery(query, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
while (cursor.moveToNext()) { //<---------------return false here???
String result_0=cursor.getString(0);
}
if(mCursor.moveToFirst()) { do {/*String res ... your stuff*/} while (mCursor.moveToNext()); } else {/* cursor has no rows should not happend*/}
这样的东西或者在这种情况下(因为它只应该返回1行),使用if(mCursor.moveToFirst()){/*String res ... your stuff*/}else{/*cursor has no rows WTF?*/}
。 - Selvin