]> iEval git - unical.git/blame_incremental - src/ro/ieval/unical/Calendar.java
Add calendarID field to Event
[unical.git] / src / ro / ieval / unical / Calendar.java
... / ...
CommitLineData
1package ro.ieval.unical;
2
3import android.content.ContentResolver;
4import android.content.Context;
5import android.database.Cursor;
6import android.provider.CalendarContract.Calendars;
7
8final class Calendar {
9 private static final String[] PROJECTION = {
10 Calendars._ID,
11 Calendars.NAME,
12 Calendars.CALENDAR_DISPLAY_NAME,
13 Calendars.VISIBLE,
14 Calendars.ACCOUNT_NAME,
15 Calendars.ACCOUNT_TYPE,
16 };
17
18 /** Calendar ID */
19 public final long _id;
20 /** Calendar name */
21 public final String name;
22 /** Calendar display name */
23 public final String displayName;
24 /** Calendar visibility (false - do not show events associated with this calendar, true - show events associated with this calendar) */
25 public final boolean visible;
26 /** Name of the account used to sync this calendar */
27 public final String accountName;
28 /** Type of the calendar used to sync this calendar */
29 public final String accountType;
30
31 private Calendar(final long _id, final String name, final String displayName, final boolean visible, final String accountName, final String accountType) {
32 this._id=_id;
33 this.name=name;
34 this.displayName=displayName;
35 this.visible=visible;
36 this.accountName=accountName;
37 this.accountType=accountType;
38 }
39
40 public static Calendar[] getAllCalendars(final Context context){
41 final ContentResolver cr=context.getContentResolver();
42 final Cursor cursor = cr.query(Calendars.CONTENT_URI, PROJECTION, null, null, null);
43 cursor.moveToFirst();
44 final Calendar[] calendars = new Calendar[cursor.getCount()];
45 for(int i=0;i<calendars.length;i++)
46 calendars[i]=new Calendar(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getInt(3)!=0, cursor.getString(4), cursor.getString(5));
47 return calendars;
48 }
49}
This page took 0.019865 seconds and 4 git commands to generate.