Vineesh TP
Vineesh TP

Reputation: 7973

Calendar Events - filter user created events - Android

I am trying to get the calendar events, I used the code below,

 public static  ArrayList<CalendarEvents>calendarEvents;
 calendarEvents = new ArrayList<CalendarEvents>();

 String[] projection = new String[] { "calendar_id", "title", "description","dtstart", "dtend","organizer", "eventLocation"};
Cursor cursor = context.getContentResolver()
                .query(
                        Uri.parse("content://com.android.calendar/events"),projection
                        , null,
                        null, null);

The result getting all the evnets including birthdays, hloydays,etc... I want to filter user created events.

Upvotes: 0

Views: 526

Answers (1)

Beena
Beena

Reputation: 2354

To filter your events. You must have some unique constraint. Let say in my case, my title contains some significant letters. So i had compared it by title. You can also compare by Events.EVENT_COLOR

  Uri eventUri =  Events.CONTENT_URI;
  int result = 0;
  String projection[] = {Events._ID, Events.TITLE};
  Cursor cursor = mContext.getApplicationContext()
            .getContentResolver().query(eventUri,
                    projection,
                    Events.TITLE + " = ? ",
                    new String[]{title},
                    null);

Upvotes: 1

Related Questions