2011-09-28 80 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