19

We've got an application that places dots in a month view where calendar events occur. We're using the calendar content provider to polulate the view.

The only problem is we query the content provider around 30 times per month: 1 - 30 november. So we get the correct number of instances per day. This way the content provider itself utilizes recurrence rules and 'multi-day' events. For instance: We have an event that takes place from 4 - 9 november. Querying the content provider on a daily basis we'll get the event back at: 4, 5, 6, 7, 8 and 9 november. This is obviously correct. But this has a very negative effect on the performance. On the other hand if I query just once: 1-30 nov, I'll only get the same event back just once. So I need to do some calculations on my own to define in which cells the event should appear.

So then, I was wondering if there is an helper or utility that does this for me: 1 query: But 5 times a seperate instance for an event that occurs more then once in that timespan.

basvk
  • 4,437
  • 3
  • 29
  • 49
  • I think you should try to run the query on Instances using a non-standard projection that differentiates the returned records for each day. There must be some field that makes the 4, 5, etc. instances distinct from each other – Jose_GD Apr 21 '14 at 22:15

2 Answers2

0

You can query the fields rrule, dtstart and dtend from the CalendarContract.Events URI and use them to calculate the specific dates. Check this link for description on the field's meaning and also this link.

Community
  • 1
  • 1
Mohamed_AbdAllah
  • 5,311
  • 3
  • 28
  • 47
  • Shouldn't you get what you want if you query for instances, instead of events https://developer.android.com/guide/topics/providers/calendar-provider.html#query-instances ? – mtotschnig Nov 14 '13 at 13:55
  • For recurrence rules it does, only for events that have a different start and end-time it doesn't. – basvk Nov 18 '13 at 07:13
0

Why don't you check Instances table of Calendar database, I faced a similar performance issue and this table resolved that. It basically holds all the recurrences of events as a separate instances, in short if a event is bound to occur for next 5 days this table will have five entries for same event detailing its attribute.

http://developer.android.com/reference/android/provider/CalendarContract.Instances.html

Hope it helps, Techfist

Techfist
  • 4,314
  • 6
  • 22
  • 32