title: Adding Event in Android Calendar
body: <pre><code>private void setEvent(){        
      long startMilis = 0;
      int mCalId = 1;
      long endMilis = 0;
      Calendar beginTime = Calendar.getInstance();
      beginTime.set(2013, 1, 29, 9, 10);
      startMilis = beginTime.getTimeInMillis();  
      Calendar endTime = Calendar.getInstance();
      endTime.set(2013, 1, 30, 10,10);
      endMilis = endTime.getTimeInMillis();
  
      ContentResolver cr = getContentResolver();
      ContentValues values = new ContentValues();
      values.put(Events.CALENDAR_ID, mCalId);
      values.put(Events.DTSTART, startMilis);
      values.put(Events.DTEND, endMilis);
      values.put(Events.TITLE,"Special Event");
      values.put(Events.DESCRIPTION, "Group Activity");
      values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles");
      Uri uri = cr.insert(Events.CONTENT_URI, values);
      Toast.makeText(this, "Event Added", Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>This is snippet of my code where i want to add Event to the android calendar. Code works fine.</p>
  
  <p>But when tested on device, <strong>The specified event does not actually get added and does not appear in calendar</strong>.Code is totally Error free and i have provided necessary permissions. </p>
  
  <p>Can someone please tell me where exactly i am doing wrong.</p>