Subba
Subba

Reputation: 637

Notification/Event for row and column level observation in Content Provider

I have content provider which has one Table. I would like to know when ever the table rows are modified. I am using Content Observer for the Table URI, which does tell when the table is modified. However it does not give much information about which row is modified, also which columns are modified. I am looking for something similar to iOS API "handleManagedObjectContextDidChangeNotification".Is there any Open source library or API available for row and column level observation?

Upvotes: 1

Views: 327

Answers (2)

danny117
danny117

Reputation: 5651

Send an id based URI to your contentobserver. The contentObserver can then use the id to get to the row that was changed.

example rowid 323 of mytable in uri.

content://com.example/mytable/323

Sorry I don't have access to my android dev from this pc or I could give a more accurate example.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007359

ContentObserver, and the whole ContentProvider framework, does not support what you want.

If the provider and its consumers are in the same app, you can use an event bus to raise more fine-grained events. Common event bus implementations include LocalBroadcastManager, greenrobot's EventBus, and Square's Otto.

If the provider and its consumers are in separate app, you will be limited to using system-level broadcasts or similar IPC mechanisms for which you can better control the protocol.

Upvotes: 3

Related Questions