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?
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.
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.
© 2022 - 2024 — McMap. All rights reserved.