数据更改后 CursorLoader 不更新 [英] CursorLoader not updating after data change

查看:20
本文介绍了数据更改后 CursorLoader 不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小应用程序,试图了解 LoaderManagerCursorLoader 类的功能.

I have created a small application, trying to understand the functionality of the LoaderManager and CursorLoader-classes.

我已经在我的 FragmentActivity 类上实现了 LoaderCallbacks 并且一切正常,除了当我通过 ContentResolver.update 更新我的数据时()ContentResolver.insert()-methods,onLoadFinished() 没有被调用,因此我的数据没有更新.

I have implemented LoaderCallbacks<Cursor> on my FragmentActivity-class and everything works fine, except the fact that when I update my data via ContentResolver.update() or ContentResolver.insert()-methods, onLoadFinished() is not called and as a result my data doesn't update.

我有一个自定义的 ContentProvider,我想知道问题是否出在我的 ContentProvider 中,没有通知数据已更改或其他原因.

I have a custom ContentProvider and I am wondering if the problem is in my ContentProvider not notifying that the data changed or something else.

推荐答案

你是否在 Cursor 上调用了 setNotificationUri(ContentResolver cr, Uri uri) 然后在 Cursor 中返回它代码>ContentProvider.query()?

Did you call setNotificationUri(ContentResolver cr, Uri uri) on the Cursor before returning it in ContentProvider.query()?

您是否在 ContentProvider 的插入"方法中调用了 getContext().getContentResolver().notifyChange(uri, null)?

And did you call getContext().getContentResolver().notifyChange(uri, null) in the 'insert' method of your ContentProvider?

要在您的 ContentProvider 中获取 ContentResolver 调用 getContext().getContentResolver().

To get a ContentResolver call getContext().getContentResolver() in your ContentProvider.

这篇关于数据更改后 CursorLoader 不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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