开发者

Android - Notifying observers of changes in an sqlite query/view

I'm developing an application where I need to update a DB, and then no开发者_JAVA技巧tify interested observers if the updates have changed what they are observing. It seems to me that an obvious way of doing this would be to define triggers which invoke a callback when the data being observed has changed (e.g. see http://www.mail-archive.com/sqlite-users@sqlite.org/msg32753.html). However, the Android SQLite bindings don't appear to support user defined functions, which kills this idea. Can anyone offer another suggestion of how I might do this?

I can probably implement a change notification mechanism without involving the database, but I would rather not, as a good part of the reason for using an off the shelf database is to get this kind of functionality...

Cheers, Dunk


Duncan, can you give us a little background on what it is that you're trying to achieve through doing this? It seems that you're programmatically writing information into the database from within your application and then you may or may not want to also visibly notify the user? If this is the case I'm not sure there would need to be a separate database trigger concept to control notification. If these are disassociated activities or there is some other substantial separation I think you may want to look at writing your own custom intent to be fired during the database write and setting up the "interested observers'" activity to receive it.

Without more robust support for the SQLite implementation I think that handling this in your application is the best you can shoot for.

Android Intents Documentation: http://developer.android.com/guide/topics/intents/intents-filters.html

Custom Intent Example: http://thinkandroid.wordpress.com/2010/02/02/custom-intents-and-broadcasting-with-receivers/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜