ContentResolver notifyChange方法是否也通知Uri的细节? [英] Does ContentResolver notifyChange method notifies also detail Uri's?

查看:319
本文介绍了ContentResolver notifyChange方法是否也通知Uri的细节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用数据期间,我将notifyChangeUri结合使用.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆