Getting compile error on ContentResolver.Insert() for creating event on Android platform

Noor.3620Noor.3620 USMember

I am now trying to create an event for Android platform. I am using Xamarin Forms but writing platform specific code for creating event on Android.
I went through the docs

but I am getting the error "An object reference is required for the non-static field, method or property ... " for the following line.

ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);

Any help will be greatly appreciated


  • any idea about this one ?

  • JoaoAmaroJoaoAmaro USMember

    ContentResolver is part of Context class. Similar to the getContentResolver() method in Android.

    So you need to obtain your ContentResolver from a Context. Like an Activity or something like that.

  • HimanshuDwivediHimanshuDwivedi USMember ✭✭

    Try this:
    Forms.Context.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);

  • SergioFariasSergioFarias USMember ✭✭

    I have same issue

Sign In or Register to comment.