2011-09-28 82 views
1

我正在查詢android日曆數據庫並尋找具有特定「iCalGUID」的事件。android android.database.sqlite.SQLiteException中的SQL錯誤:無法識別的令牌

這裏是我使用的查詢

final Cursor cursor = resolver.query(uri.getCalendarUri(), 
         null, "events.iCalGUID=" + uid, null, null); 

當前uid是0804eaa1-3472-43df-96c2-af73ae5c31ab

不過,雖然執行這個查詢

android.database.sqlite.SQLiteException: unrecognized token: "0804eaa1": , 
while compiling: SELECT originalEvent, visibility, rrule, hide_declined, reminder_type, hasAlarm, 
description AS suggest_text_2, rdate, transparency, timezone, dtstart, _sync_time, hasAttendeeData, 
commentsUri, description, reminder_duration, htmlUri, _sync_account, _sync_version, hasExtendedProperties, 
last_update_time, eventLocation, dtend, allDay, organizer, sync_source, deleted, url, originalInstanceTime, alerts_vibrate, importance, selfAttendeeStatus, eventTimezone, ownerAccount, _sync_account_type, lastDate, guestsCanModify, guestsCanSeeGuests, exrule, selected, title, _id, _sync_id, alerts_ringtone, calendar_id, access_level, _sync_local_id, title AS suggest_text_1, originalAllDay, iCalGUID, _sync_dirty, duration, parentID, color, 
guestsCanInviteOthers, 
exdate, eventStatus FROM view_events WHERE (1) 
AND (events.iCalGUID=0804eaa1-3472-43df-96c2-af73ae5c31ab) 
我得到一個異常

我怎麼能在android 中做到這一點謝謝。

回答

1

試試這個:

final Cursor cursor = resolver.query(uri.getCalendarUri(), 
         null, "events.iCalGUID=\"" + uid + "\"", null, null); 
+0

感謝。有用。讓我問你的幫助。現在我得到錯誤列dosen't存在。所以我改變了events.iCalGUID到view_events.iCalGUID,它的工作原理。這是查詢事件列iCalGUID的正確方法嗎? – Zach

+0

這取決於你的表,它的格式應該是'yourtablename.yourcolumname = ...' – Caner

+0

我在Android上使用默認日曆數據庫 – Zach