我有一個問題,當我使用WHERE子句執行查詢時,它不返回任何結果,但如果我將WHERE作爲空值執行,它將執行所有記錄並查找匹配項。任何人都可以告訴我我的查詢有什麼問題嗎?SQLite Android查詢返回任何結果
在我的代碼可以說contactURI等於「內容://com.android.contacts/contacts/lookup/953i7d73a639091bc5b6/164」和contactUriId等於「164」
// Put data in the contactURI
contactURI = data.getData();
// get the contact id from the URI
contactUriId = contactURI.getLastPathSegment();
//TEST TODO Fix URI Issue
String [] PROJECTION = new String [] { Data.CONTACT_ID, Data.LOOKUP_KEY };
Cursor cursor = this.managedQuery(Data.CONTENT_URI, PROJECTION, Data.CONTACT_ID + "=?" + " AND "
+ Data.MIMETYPE + "='*'",
new String[] { String.valueOf(contactUriId) }, null);
Log.e(DEBUG_TAG, contactUriId+"-164-");
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()) {
Log.v(DEBUG_TAG, "lookupKey for contact: " + cursor.getString(1) + " is: -" + cursor.getString(0) + "-");
if(cursor.getString(0).equals("164")){
Log.e(DEBUG_TAG, "WE HAVE A MATCH");
}
}
這是我的日誌...
05-14 19:08:40.764: D/OpenGLRenderer(21559): Flushing caches (mode 0)
05-14 19:08:46.944: E/MyDebug(22269): 164-164-
太棒了!這解決了我的問題!非常感謝Sam!我會投票,但我沒有足夠的代表。 – BinaryNexus