Cool. Mr. Jens, you're right.

First, I checked the content_id,
then I set the content_id to 1.
Succeed.

Thank you.

Also thanks to Mr Mr. Murphy.

On 10月11日, 下午7时48分, Jens <[email protected]> wrote:
> You're adding an event that's not linked to a row in the calendars
> table for one.
>
> Typically you need to set the value of "calendar_id" to something.
> This "something" better be a valid _id value from the calendars table
> or your app will just be filling the provider with crap.
>
> If you're going to be messing around in undocumented providers you
> should probably start by looking at the provider code itself:
>
> http://android.git.kernel.org/?p=platform/packages/providers/Calendar...
>
> Also.. the provider is a bit peculiar on all-day events.. plz make
> sure you're pushing them in in UTC-time with the event time zone set
> to UTC also. Look at the implementation in the Calendar app itself:
>
> http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;...
>
> --
>
> (or you could just do it with GDATA as M.Murphy suggests and push your
> messages via HTTP up to Google which should sync it back to the device
> sooner or later).
>
> On 8 Okt, 12:40, Kapuddi <[email protected]> wrote:
>
> > Hello, All:
>
> > when I insert one new Calendar Event into Google calendar from my app,
> > the log message was given:
> > ================================================================================
> > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): Error inserting
> > transparency=0 dtstart=1285891200000 title=TestCalendar _sync_dirty=1
> > dtend=1285891200000 visibility=0 allDay=1 lastDate=1285950628697
> > hasAlarm=0 eventStatus=1 into table  Events
> > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):
> > android.database.sqlite.SQLiteConstraintException: error code 19:
> > constraint failed
> > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):     at
> > android.database.sqlite.SQLiteStatement.native_execute(Native Method)
> > ================================================================================
>
> > would you please tell me how to solve it?
>
> > Best Regards,
>
> > Kapuddi
>
> > ================================================================================
> > Next is my sample code:
> > // Platform: android 2.2 froyo
>
> >    private static final String calendarcontentStr =
> > "content://com.android.calendar/events";
>
> >    ContentValues event = new ContentValues();
>
> >    //event.put("title", mAct.getString(R.string.read) + ": " + title);
> >    event.put("title", "TestCalendar");
>
> >    long startTime = startC.getTimeInMillis();
> >    long endTime = endC.getTimeInMillis();
>
> >    event.put("dtstart", startTime);
> >    event.put("dtend", endTime);
> >    //event.put("allDay", 1);
> >    event.put("eventStatus", 1);
> >    event.put("visibility", 0);
> >    event.put("transparency", 0);
> >    event.put("hasAlarm", 0);
>
> >    Uri eventsUri = Uri.parse(calendarcontentStr);
> >    Uri uri = mAct.getContentResolver().insert(eventsUri, event);

-- 
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

Reply via email to