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

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

问题描述

我创建了一个小型应用程序,试图了解 LoaderManager CursorLoader -classes <的功能/ P>

我已实施 LoaderCallbacks&LT;光标&GT; 我的 FragmentActivity 级,一切工作正常,但事实上,当我通过 ContentResolver.update更新我的数据() ContentResolver.insert() - 方法, onLoadFinished()不叫,结果我的数据不会更新。

我有一个自定义的ContentProvider,我想知道如果这个问题是在我的ContentProvider不通知的数据改变或别的东西。

解决方案

你叫 setNotificationUri(ContentResolver的CR,开放的URI)光标 ContentProvider.query()返回之前,

和你叫的getContext()。getContentResolver()。有NotifyChange(URI,空)在你的 ContentProvider的<插入方法/ code>?

编辑:

要获得 ContentResolver的呼叫的getContext()。getContentResolver()的ContentProvider

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

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.

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.

解决方案

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

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

EDIT:

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

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

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