Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Calendar Provider: Is there a unique identifier for events, usable across multiple devices?

I'm using the Android Calendar Provider to display events. I'm also associating the events with images from a local app database by using the EVENT_ID of the event as a reference.

I'm now wondering if it is possible to keep the same reference across multiple devices?

I understand that for the account_type = 'com.google', the GoogleCalendarSyncAdapter uses CalendarContract.EventsColumns.SYNC_DATA1 to store the googleID of the event. However, it seems that this is not a reliable way to access the data since usage of the SYNC_DATA columns may change at any time and can only be modified by the SyncAdapter.

Is there any other way that I can keep the reference to a calendar provider event across devices?

like image 700
Christopher Masser Avatar asked Jul 24 '13 10:07

Christopher Masser


People also ask

What is Android providers calendar?

The Calendar Provider is a repository for a user's calendar events. The Calendar Provider API allows you to perform query, insert, update, and delete operations on calendars, events, attendees, reminders, and so on. The Calendar Provider API can be used by applications and sync adapters.

How do I import a calendar into Android Studio?

Step 1: Create a new project and you will have a layout XML file and java file. Your screen will look like the image below. Step 2: Open your xml file and add CalendarView and TextView. And assign id to TextView and CalendarView.


1 Answers

Embed image IDs into your events

A while ago I had a similar problem with CalendarContract and I solved it by embedding a unique UID tag into the event description text. Clients would parse that tag and retrieve a common UID. That ID is generated on one of the clients using the UUID Java class. However, in my case I was more interested in identifying events created with my app.

In your case I assume that your image database references are stable IDs that are consistent across all app installations. You could insert a tag into the event description text that references the image from your DB such as:

<myapp:imgid_1234>

Alternatively you could also add a special "resource type" attendee to your event that adds that image reference to an event: [email protected]. This option would keep the event description clean and may lower accidental deletion through the user.

like image 107
tiguchi Avatar answered Sep 30 '22 20:09

tiguchi