title: Null pointer exception when accessing Google Calendar
body: <p>I am writing a android app that need to <strong>insert event to Google Calendar</strong>. I run my app in my two android phone and thay are all success. However, some crash reports from others are received. They have <strong>null pointer exception</strong> in the last line of the following code.</p>
  
  <p>(BTW, I have already handled two different URIs of google calendar by following <a href="https://stackoverflow.com/questions/846942/is-there-a-way-to-access-the-calendars-entries-without-using-gdata-java-client">Is there a way to access the calendar&#39;s entries without using gdata-java-client?</a>)</p>
  
  <p><strong>Entire source code file: <a href="http://gonow.no-ip.org/hkpl/GoogleCalendar.java" rel="nofollow noreferrer">http://gonow.no-ip.org/hkpl/GoogleCalendar.java</a></strong></p>
  
  <p>I call function addEvent in another class by this</p>
  
  <pre><code>GoogleCalendar.addEvent(getContentResolver(),EVENT_TITLE,CONTENT);
  </code></pre>
  
  <p>Extracted:</p>
  
  <pre><code>ContentValues event = new ContentValues();
  event.put("title", title);
  event.put("description", description);
  event.put("calendar_id",calId);      
  Calendar cal = Calendar.getInstance();
  cal.setTime(date);
  cal.add(Calendar.DAY_OF_MONTH, 1);     
  long start = cal.getTime().getTime();
  event.put("dtstart", start);        
  cal.add(Calendar.DAY_OF_MONTH, 1);  
  long end = cal.getTime().getTime();        
  event.put("dtend", end);        
  event.put("hasAlarm",1); 
  event.put("allDay", 1);           
  Uri newEvent = cr.insert(Uri.parse(calanderEventURL), event); &lt;-- exception here
  </code></pre>
  
  <hr>
  
  <p>Crash report here</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: An error occured while executing
    doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:200) at
    java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
    at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
    at java.lang.Thread.run(Thread.java:1019) Caused by:
    java.lang.NullPointerException at
    android.os.Parcel.readException(Parcel.java:1328) at
    android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
    at
    android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
    at
    android.content.ContentProviderProxy.insert(ContentProviderNative.java:408)
    at android.content.ContentResolver.insert(ContentResolver.java:604) at
    ming.hkpl.GoogleCalendar.addEvent(GoogleCalendar.java:93)</p>
  </blockquote>