I create a new calender with this code. Android 2.3.5
if(Build.VERSION.SDK_INT < 14)
{
ContentValues calendar = new ContentValues();
calendar.put("_sync_account", "Com2Cal");
calendar.put("_sync_account_type", "LOCAL");
calendar.put("name", "Com2Cal");
calendar.put("displayName", "Com2Cal");
calendar.put("color", 0xFF008080);
calendar.put("access_level", 700);
calendar.put("sync_events", 1);
calendar.put("timezone", TimeZone.getDefault().getID());
calendar.put("ownerAccount", "Com2Cal");
calendar.put("hidden", 0);
Uri conentUri;
if(Build.VERSION.SDK_INT >= 8)
{
conentUri =
Uri.parse("content://com.android.calendar/calendars");
}
else
{
conentUri = Uri.parse("content://calendar/calendars");
}
Uri newRow =
context.getContentResolver().insert(createCompleteUri(conentUri), calendar);
Log.v(TAG, newRow.toString());
}
and
private static Uri createCompleteUri(Uri uri)
{
Uri.Builder b = uri.buildUpon();
b.appendQueryParameter("caller_is_syncadapter", "true");
b.appendQueryParameter("account_name", "Com2Cal");
b.appendQueryParameter("account_type", "LOCAL");
Uri calUri = b.build();
Log.d("completeUri", calUri.toString());
return calUri;
}
The calendar was created. I see him in the calendar app. But after the
restart, the calendar no longer exists. Why?
I add the calendar in a onClick event of a activity. I do not own
SyncAdapter or so.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en