views:

29

answers:

0

I'm developing an android app that creates a calendar on the phone the first time the application is installed. When I create an event, either programmatically or using the device itself, the event will show up in the calendar but its title is missing. I'm testing my code on HTC nexus one.

Since I'm getting the same behavior when creating the event through my code or through the device, I'm suspecting there is a problem in the code I wrote to create a new calendar account. I am doing so by adding a new field in the calendars table of the calendar.db database, whose URI is: "content://com.android.calendar/calendars"

 private Uri addNewCalendar() {

   if (!calendarExists()) {

       ContentResolver contentResolver = mContext.getContentResolver();

       ContentValues cv = new ContentValues();
       cv.put(Calendar.Calendars._SYNC_ACCOUNT, mAccount.name);
       cv.put(Calendar.Calendars._SYNC_ACCOUNT_TYPE, mAccount.type);
       cv.put(Calendar.Calendars._SYNC_TIME, new Date().getTime());
       cv.put(Calendar.Calendars.URL, "http://www.example.com");
       cv.put(Calendar.Calendars.NAME, mAccount.name);
       cv.put(Calendar.Calendars.DISPLAY_NAME, mAccount.name);
       cv.put(Calendar.Calendars.HIDDEN, 0);
       cv.put(Calendar.Calendars.COLOR, 14417920);
       cv.put(Calendar.Calendars.ACCESS_LEVEL, 700);
       cv.put(Calendar.Calendars.SELECTED, 1);
       cv.put(Calendar.Calendars.SYNC_EVENTS, 1);
       cv.put(Calendar.Calendars.TIMEZONE, "GMT");
       cv.put(Calendar.Calendars.OWNER_ACCOUNT, mAccount.name);

       Uri uri = contentResolver.insert(Calendar.Calendars.CONTENT_URI.buildUpon().build(), cv);

       return uri;
      }
      return null;
    }

Also, when checking whether the title field of the event is actually written in the database, I found it is saved correctly. I can see the event title when I try to edit the event on the phone.

Anyone has an idea why I'm having this problem? If you need more information, please let me know.