ContentResolver notifyChange方法是否也通知Uri的细节? [英] Does ContentResolver notifyChange method notifies also detail Uri's?
问题描述
在应用数据期间,我将notifyChange
与Uri
结合使用.
During applying data I use notifyChange
with an Uri
.
比方说我通知了content://com.package.my/items
.
我还具有显示content://com.package.my/items/1
中数据的详细信息Activity
.
I have also detail Activity
that displays data from content://com.package.my/items/1
.
通知一般" Uri
是否还会导致通知详细" Uri
?
Does notifying 'general' Uri
results also in 'detail' Uri
being notified?
推荐答案
方法notifyChange
发送有关详细URI的通知.
但是,如果在ContentResolver.registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer)
上注册ContentObserver
,则可以注册基本Uri
,以便在任何后代Uri
被更改(用于发送更改通知)时得到通知.
The method notifyChange
sends a notification for the detailed URI.
But if you register a ContentObserver
at ContentResolver.registerContentObserver(Uri uri, boolean notifyForDescendents, ContentObserver observer)
you can register a base Uri
to be notified if any descendant Uri
has been changed (is used to send change notification).
我假设您有一个ContentProvider
,并且您通过ContentResolver
从该ContentProvider
中查询了Cursor
.如果在ContentProvider.query()
方法中返回的Cursor
上设置了通知URI,则如果通知URI或其任何后代发生更改,则CursorAdapter
将自动更新视图(请参见
I assume you have a ContentProvider
and that you query a Cursor
from that ContentProvider
through a ContentResolver
. If you set the notification URI on the Cursor
that you return in the ContentProvider.query()
method, your CursorAdapter
will automatically update the view if the notification URI or any of its descendants change (see source of Cursor). If you change the data with you ContentProvider
be sure to send a notification in update,insert,delete
of your ContentProvider
.
这篇关于ContentResolver notifyChange方法是否也通知Uri的细节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!