title: Create new local calendar in android pre ICS
body: <p>I have been struggelig for weeks on this, so now I hope someone here can give me some clarity.</p>
  
  <p>The project I'm working on(pre ICS) includes logging on to my company's server, getting my future work schedule and store this on my phone in a seperate calendar. This calendar should them be viewable in all the major calendar apps (Jorte, Business Calendar, Smooth Calendar ++).
  I got the schedule parsed and stored on the phone in an SQLite database. But my struggle is getting from there to create a seperate local calendar and store all the events there. I assumed I had to create an account for this (not to mess up any other account on the phone. That worked well with the code:</p>
  
  <pre><code>AccountManager man = (AccountManager) getSystemService(ACCOUNT_SERVICE);
  Account acc = new Account("myCalendar", "com.lumabyte.mycalendar");
  </code></pre>
  
  <p>But I thought creating a calendar on that account would be quite easy with:</p>
  
  <pre><code>ContentValues calendar = new ContentValues();
  calendar.put("_sync_account", "myCalendar"); // My account
  calendar.put("_sync_account_type","com.lumabyte.mycalendar"); 
  calendar.put("name", "myCalendar");
  calendar.put("displayName", "myCalendar");
  calendar.put("hidden",0);
  calendar.put("color",0xFF008080);
  calendar.put("access_level", 700);
  calendar.put("sync_events", 1);
  calendar.put("timezone", "Europe/Paris");
  calendar.put("ownerAccount", sync_account);
  Uri calendarUri = Uri.parse(getCalendarUriBase() + "calendars");
  this.getContentResolver().insert(calendarUri, calendar);
  </code></pre>
  
  <p>The function getCalendarUriBase():</p>
  
  <pre><code>private String getCalendarUriBase() {
  
      String calendarUriBase = null;
      Uri calendars = Uri.parse("content://calendar/calendars");
      Cursor managedCursor = null;
      try {
          managedCursor = this.managedQuery(calendars, null, null, null, null);
      } catch (Exception e) {
          // eat
      }
  
      if (managedCursor != null) {
          calendarUriBase = "content://calendar/";
      } else {
          calendars = Uri.parse("content://com.android.calendar/calendars");
          try {
              managedCursor = this.managedQuery(calendars, null, null, null, null);
          } catch (Exception e) {
              // eat
          }
  
          if (managedCursor != null) {
              calendarUriBase = "content://com.android.calendar/";
          }
  
      }
  
      managedCursor.close();
  
      return calendarUriBase;
  }
  </code></pre>
  
  <p>The manifest includes:</p>
  
  <pre><code>  &lt;uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/&gt;
    &lt;uses-permission android:name="android.permission.USE_CREDENTIALS" /&gt; 
    &lt;uses-permission android:name="android.permission.MAMAGE_ACCOUNTS"/&gt;
    &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;    
    &lt;uses-permission android:name="android.permission.READ_CALENDAR"&gt;
    &lt;uses-permission android:name="android.permission.WRITE_CALENDAR"&gt;    
  </code></pre>
  
  <p>and my authenticator.xml is like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"  
      android:accountType="com.lumabyte.mycalendar"
      android:icon="@drawable/icon"
      android:smallIcon="@drawable/icon"
      android:label="@string/authenticator_label"
  /&gt;
  </code></pre>
  
  <p>I do not get any error messages, but only the account is created, and not the calendar. Is there a small error in the code, or have I misunderstood the whole concept. I know there is no API pre ICS, and that there is risks involved. But I need it done anyway. Prefeably stable on as many phones as possible. Any help or examples would be greatly appreciated.</p>
  
  <p>I'll work with ICS later as I understand they now have i public API for that.</p>
  
  <p>r</p>