Now events are added to calendar. Edit also works now
[unical.git] / src / ro / ieval / unical / Event.java
index f033533ecbb619b9e39e1668ec5a75da0d669f7c..a7fce60a038b1a62b1b0e5a44a73f8146389a34a 100644 (file)
@@ -1,6 +1,7 @@
 package ro.ieval.unical;
 
 import java.util.ArrayList;
+import java.util.TimeZone;
 
 import android.content.ContentResolver;
 import android.content.ContentValues;
@@ -106,10 +107,24 @@ final class Event implements Parcelable{
                return  r.toArray(new Event[r.size()]);
        }
 
+    public static long getUnicalId(final Context context) {
+        for(final Calendar calendar : Calendar.getAllCalendars(context))
+            if(calendar.name.equals("unical")) return calendar._id;
+
+        return 0;
+    }
+
+
     public void insert(final Context context) {
-        final ContentResolver cr=context.getContentResolver();
-        //cr.insert(Uri.withAppendedPath(Events.CONTENT_URI));
-        //cr.notifyChange();
+       ContentValues cv = new ContentValues();
+        cv.put("calendar_id",calendarID);
+        cv.put("title",title);
+        cv.put("description",description);
+        cv.put("dtstart",dtstart);
+        cv.put("dtend",dtend);
+        cv.put("eventTimezone", TimeZone.getDefault().getID());
+
+        Uri url = context.getContentResolver().insert(Events.CONTENT_URI, cv);
     }
 
        public void delete(final Context context){
This page took 0.010398 seconds and 4 git commands to generate.