Calendar for Android

I am trying to put items on a calendar and cannot figure out how to encode it. This is what I still have, but it inserts it into the main calendar.

String calName; String calId = null; String[] projection = new String[] { "_id", "name" }; Uri calendars = Uri.parse("content://calendar/calendars"); Cursor managedCursor = managedQuery(calendars, projection, null, null, null); ContentValues event = new ContentValues(); event.put("calendar_id", calId); event.put("title", strTitle); event.put("description", strDescription); event.put("eventLocation", strLocation); event.put("dtstart", StartTime); event.put("dtend", EndTime); Uri eventsUri = Uri.parse("content://calendar/events"); Uri calUri = getContentResolver().insert(eventsUri, event); 

So my questions are:

  • How to create your own calendar to post events in

  • How to insert my events into this calendar (using the code above or a new code)

  • How to check if an existing event already exists

~~~ UPDATE: ~~~

What I'm trying to do is that my users will enter the title and date, and my application will take that title and date, put them in the database (for now, all I have done), and now I want to take the title and date and put them in a special calendar dedicated only to my applications. The first thing I need to do is create a new calendar. How to embed events in this calendar, which helps me make the code below. Still playing with him. Than I want to restart my application and check if the event exists. That's all.

+6
source share
3 answers

First of all, changing the content resolution changes from 2.2, I think, from content://calendar/calendars to content://com.android.calendar/calendars .

To insert an event, get an event Check this code

https://github.com/Rabgs/AndroidLib_Google-Calendar/blob/master/src/net/mobiwide/agenda/google/GoogleAgenda.java

You will find everything you need and how to deal with changing the resolution of content on different platforms.

+2
source
0
source

To update Google Calendar, use the Google GData API of Google .

0
source

Source: https://habr.com/ru/post/890303/


All Articles