Android: Working with the Android Calendar
<p>I am trying to add entry to the Android Calendar(2.2),but i have ever got some error.
I tried a lot of test but without success.What is wrong please?
Sorry for my english.</p>

<p>Source code:</p>

<pre><code>String calName; 
        String calId = null;
        String[] projection = new String[] { "_id", "name" };
        Uri calendars = Uri.parse("content://com.android.calendar/calendars");
        Cursor managedCursor = managedQuery(calendars, projection, "selected=1", null, null);
        ContentValues event = new ContentValues();
        DateFormat date = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");

        long time = System.currentTimeMillis();
        String timeStr = date.format(time);
        Log.d(TAG, "Value of timeStr: " + timeStr);



        if (managedCursor.moveToNext()) {
            calName = managedCursor.getString(managedCursor.getColumnIndex("name"));
            calId = managedCursor.getString(managedCursor.getColumnIndex("_id"));
            event.put("calendar_id", calId);
            event.put("title", "Event Title");
            event.put("description", "Description");
            event.put("eventLocation", "New York");
            event.put("dtstart", timeStr );
            event.put("dtend", timeStr);
            Uri eventsUri = Uri.parse("content://com.android.calendar/events");
            Uri url = getContentResolver().insert(eventsUri, event);


            }
</code></pre>
