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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With