2015-02-07 95 views
2

我需要更新日历事件的描述。安卓日历事件更新后设置错误日期

这是我的代码:

ContentValues values = new ContentValues(); 
values.put(Events.DESCRIPTION, "my description"); 
Uri updateUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId); 
int update = mContentResolver.update(updateUri, values, null, null); 

我在写logcat中之前和之后我打电话给我的代码:

之前(对我来说OK):

DTSTART = 07/02/2015 00:00:00
DTEND = 07/02/2015 23:59:59

后(错误):

DTSTART = 2015年6月2日01:00:00
DTEND = 2015年7月2日01:00:00

所以我的事件被移动到前一天。 为什么会发生这种情况,我该如何解决?

+0

你打电话给我的代码之前和之后是什么意思?并发布代码如何设置日期 – Apurva 2015-02-18 10:32:34

回答

1


传递DTSTART和DTEND与您要更新的说明一起,将解决这个问题,但在重复事件DTEND是不允许的情况下记得那么添加该

ContentValues values = new ContentValues(); 
values.put(Events.DESCRIPTION, "my description"); 
values.put(Events.DTSTART,"your event start time in milliseconds here"); 
values.put(Events.DTEND,"your event end time in milliseconds here"); 
Uri updateUri = ContentUris.withAppendedId(Events.CONTENT_URI, eventId); 
int update = mContentResolver.update(updateUri, values, null, null); 

支票希望这会有所帮助:)