我用这段代码创建了一个新的日历。安卓 2.3.5
public long CreateNewCalendar(String nameSchedule) {
try{
ContentValues calendar = new ContentValues();
calendar.put("_sync_account", nameSchedule); // My account
calendar.put("_sync_account_type", "com.google");
// calendar.put("_sync_id", 1); // null
calendar.put("name", nameSchedule);
calendar.put("displayName", nameSchedule);
calendar.put("hidden", 0);
calendar.put("color", 0xFF008080);
calendar.put("access_level", 700);
calendar.put("selected", 1); // 0
calendar.put("sync_events", 1);
// calendar.put("createdByCategory", 0); //Doesn't work on Motorola
// Droid / Milestone
calendar.put("timezone", TimeZone.getDefault().getID());
calendar.put("ownerAccount", nameSchedule);
Uri calendarUri = Uri.parse(CalendarBase);
Uri insertCalendarUri = ActivitySource.getContentResolver().insert(calendarUri, calendar);
return ContentUris.parseId(insertCalendarUri);
} catch (Exception e) {
return -1;
}
}
日历已成功创建,我可以在日历应用程序中看到它。但是重启手机后,日历就不存在了。怎么了?