我SQLite中的Android查詢:光標查詢再回到1 mCount
Cursor cursor = Application.getInstance().getContentResolver().query(DAOProvider.URI_EXECSQL, new String[]{getSingleQuery(idPatient)}, null, null, null);`
if (cursor != null && cursor.moveToFirst()) {
if(cursor.getCount() > 0)
{
String id = cursor.getString(0); // The result of all the values are null
}
}
這是查詢的結果(所有值都爲空,該表是空的):
問題是,返回count = 1,但我沒有任何記錄在我的數據庫中,我的表是空的,並且遊標認爲存在1記錄,但問題是遊標具有NULL中的所有值。
是否需要任何其他配置來檢查查詢是否有結果? 添加轉儲光標:
Dumping cursor [email protected]
0 {
id_person_patient=null
id_blood_type=null
cenRegister=null
name=null
paternalSurname=null
maternalSurname=null
sex=null
curp=null
rfc=null
registerDate=null
birthday=null
email=null
id_nationality=null
id_state=null
IFNULL(nfcp.id_statusnfc, 0)=0
COUNT(pr.id)=0
id_person_tutor=null
id_relationship=null
name=null
paternalSurname=null
maternalSurname=null
sex=null
curp=null
rfc=null
registerDate=null
birthday=null
email=null
id_nationality=null
id_state=null
IFNULL(vc.apply, 0)=0
id_person_user_alta=null
nfccount=0
}
如果不能確定moveToPosition()不能返回正確的'Cursor'內容使用'DatabaseUtils#dumpCursor'方法 – pskink
'「」「這是查詢的結果(所有的值都爲空,表爲空):」「」',不,表不是空的,你有一行(所有字段或者= 0或NULL) – pskink
問題是IFNULL(nfcp.id_statusnfc,0)= 0,這使得查詢在結果行中返回0值。 –