我有一个问题,当我使用 WHERE 子句执行查询时,它不会返回任何结果,但如果我将 WHERE 保留为 null,它将执行我的所有记录并找到匹配项。谁能告诉我我的查询有什么问题?
在我的代码中可以说contactURI等于“content://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-