Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting unique IDs for Android calendar Events

I've done quite a bit of research, and can't find how to access a truly unique ID for Calendar events int Android. I query the following URI:

Context.getContentResolver().query(Events.CONTENT_URI, null, null, null, null);

When looking through the resulting Cursor on my Galaxy Nexus, there is nothing similar to the iCalGUID form (see below) that I am looking for. However, when doing the same query on an HTC One S, I noticed that HTC has included iCalGUID as an extra column field, which returns exactly the type of ID that I'm looking for. It looks like this:

9ced5c2c-6ed9-481f-9f69-9a064810ac0f

It doesn't look like this iCalGUID field is Android SDK standard, though, so I can't get this ID on other Android phones. My question is, is there some way I can get this type of ID in a way that is standard Android? I'm targetting ICS right now, but would like to be flexible to extend this to previous versions in the future.

If there is some other type of ID that I should be using, that would be great as well. NOTE: I am not looking for the Events._ID column. I need my IDs to be unique across all devices, and all types of Accounts (Google, Exchange, Hotmail, etc.)

Thank you!

like image 593
jmhend Avatar asked Nov 04 '22 21:11

jmhend


1 Answers

The Field UID_2445 was intended for this purpose, but unfortunately it is almost never populated, and never with an actual UID.

Synchronisers can access various sync fields which in my testing always hold the event original id. The problem is the fields populated depend on the particular synchroniser, there isn't a standard. You'll need the synchroniser read permission to look at those fields.

It's not supported and I don't recommend it but you could look at account type (e.g com.android.exchange) to figure out the synchroniser then look in the field usually populated with the UID. In my testing it's Sync Data 2 for everything but Google, which is Sync Data 1.

like image 141
Daniel Roberts Avatar answered Nov 16 '22 12:11

Daniel Roberts