开发者

Query with Calendar

I am trying to build a query for fetching the events from the native calendar, i have stored description with 1 word from the these 3 words: "google", "yahoo", "stackoverflow"

For example: description="google",

As of now, i have made query as below:

Cursor eventCursor = getContentResolver().query(builder.build(),
        new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=" + calId,
        null, "startDay ASC, startMinute ASC"); 

now, i would like to make query with Description part, how do i?? of my current implementation is wrong, please show me a correct way as if you know !!!

Update:

I have done so far:

public String Fetch_Events_Detail(long From_milliseconds, String kind_website)
 {
  String event_detail = null;

  Uri.Builder builder = calendar_events_URI.buildUpon();
        //long now1 = new Date().getTime();
        ContentUris.appendId(builder, From_milliseconds);
        ContentUris.appendId(builder, From_milliseconds + DateUtils.DAY_IN_MILLIS);


       /* Cursor eventCursor = getContentResolver().query(builder.build(),
                new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=? and description = ?",
                new String[] { DatabaseUtils.sqlEscapeString(calId),  DatabaseUtils.sqlEscapeString(kind_website)}, "startDay ASC, startMinute ASC"); 
        */

        Cursor eventCursor = getContentResolver().query(builder.build(),
                new String[] {"event_id", "title", "begin", "end", "allDay","description" },开发者_JAVA百科"Calendars._id=" + calId,
                null, "startDay ASC, startMinute ASC"); 

        if(eventCursor != null)
        {

         while (eventCursor.moveToNext()) 
         {
            String uid2 = eventCursor.getString(0);
            String event_title = eventCursor.getString(1);
            String event_start = eventCursor.getString(2);
            String event_description = eventCursor.getString(5);

            try
            {
                // SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
             SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
                Date resultdate = new Date(Long.parseLong(event_start));

                event_detail=sdf.format(resultdate)+"  "+event_title;
                event_detail.trim();

                if(event_description.trim().equalsIgnoreCase(kind_website))
                { 
                 return event_detail;
                }
            }
            catch(NumberFormatException e)
            {
             Log.i("Exception raised", "");
            }
          }
        }

        return null;
 }

Thanx


Cursor eventCursor = getContentResolver().query(builder.build(),
        new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=? and description = ?",
        new String[] { DatabaseUtils.sqlEscapeString(calId),  DatabaseUtils.sqlEscapeString(description)}, "startDay ASC, startMinute ASC"); 

Try this without calId

Cursor eventCursor = getContentResolver().query(builder.build(),
        new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "description = ?",
        new String[] {DatabaseUtils.sqlEscapeString(description)}, "startDay ASC, startMinute ASC"); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜