首页 > 解决方案 > Xamarin get all data (events, reminders ) from Calendar

问题描述

How to get all data present in my Calendar using Xamarin. I am using below code and It is only returning already present holidays list. I want to get the manually added events and reminder list also.Below is the code am using

var calendarsUri = CalendarContract.Events.ContentUri;
var cursor = Forms.Context.ContentResolver.Query(calendarsUri, null, null, null, null);

if (cursor.MoveToFirst())
            {
                do
                {
                      calendarEventList.Add(new Calendar()
                      {
                          Id = cursor.GetString(cursor.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.Id)),
                          CalendarDisplayName = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName)),
                          AccountName = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Calendars.InterfaceConsts.AccountType)),
                          Title = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Title)),
                          Description = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Description)),
                          Dtstart = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtstart)),
                          Dtend = cursor.GetString(cursor.GetColumnIndex(CalendarContract.Events.InterfaceConsts.Dtend))                       
                      }); 
                 } while (cursor.MoveToNext()); 
             }

So my 'calendarEventList' contains only the holidays event. Can anyone help me with getting all the events from my Calendar.

Thank in Advance.

标签: xamarinxamarin.formscalendar

解决方案


推荐阅读