编写一个LoaderManager管理数据 [英] Writing Data managed by a LoaderManager

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

问题描述

在使用LoaderManager,我还是管理我的数据库写入我过去,让装载机拿起变化的方式吗?我在转换和添加功能的应用程序的过程中,我仍然习惯到Android平台。

When using a LoaderManager, do I still manage my database writes the way I have in the past and let the Loader pick up the changes? I am in the process of converting and adding functionality to an app and I am still getting used to the Android platform.

推荐答案

如果您使用的是 CursorLoader ,你通过的ContentProvider 您 CursorLoader ,装载机和光标将变更通知,所以一切会为你处理。

If you are using CursorLoader, and you do all your database updates via the ContentProvider you used with CursorLoader, the loader and its Cursor will be notified of changes, so everything will be handled for you.

如果您不使用 CursorLoader ,这是你的责任,以某种方式更新自己的光标。例如,我的 LoaderEx 项目有一个 SQLiteCursorLoader 与直接工作的 SQLiteOpenHelper ,它提供了插入()更新() 删除() execSql()上加载器方法,所以我们可以相应地更新光标。

If you are not using CursorLoader, it is your responsibility to somehow update your own Cursor. For example, my LoaderEx project has a SQLiteCursorLoader that works directly with a SQLiteOpenHelper, and it offers insert(), update(), delete(), and execSql() methods on the Loader, so we can update the Cursor accordingly.

这篇关于编写一个LoaderManager管理数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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