获取内容提供商的更改
我正在开发一个将远程日历与 Android 设备同步的应用程序。
一切工作正常,但现在我想通过让 Android 设备仅同步用户编辑的事件(使用 Android 日历)来使其更快一点。所以我需要知道哪些事件被编辑了。
我一直在研究 ContentObserver
但这似乎不是一个好的解决方案,因为我必须为日历中的每个事件注册一个观察者。我什至不知道如果我重新启动设备,观察者是否仍然在那里。
我提出的另一个解决方案是将所有事件的副本存储在本地数据库中。该数据库将在每次同步时更新。在每次同步之前,我们可以将该数据库与 Android 日历提供程序进行比较...
是否有更简单的方法来做到这一点?
谢谢, 吉利斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我非常确定您可以查询日历数据库以查找在特定日期之后修改的事件(这将是最近修改的事件被修改后的日期)。
该查询的成本非常低,您可以每秒左右重复一次。
编辑:我一直在查看架构中的一列来表示事件的上次修改日期,但我没有看到这一列。所以也许这不是一条可行的路线。
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.