开发者

Get changes in content provider

I'm 开发者_高级运维developing an application that syncs a remote calendar with an Android device.

Everything works fine, but now I want to make it a bit faster by letting the Android device only sync events that got edited by the user (with Android Calendar). So I need to know which events got edited.

I've been looking into ContentObserver but that doesn't seem like a good solution since I would have to register an observer for each event in the calendar. And I don't even know if the observer would still be there if I restarted the device.

Another solution I came up with is to store a copy of all events in a local database. That database would get updated on each sync. And before each sync we could compare that database with the Android Calendar provider...

Is there an easier way to do this?

Thanks, Gillis


I'm pretty sure you could query the calendar database for events modified after a certain date (which would be the date after the most recently modified event was modified).

The query would be so cheap you could repeat it every second or so.

Edit: I've been looking through the schema for a column to represent the event last modified date and I don't see one. So maybe that's not a viable route.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜