为什么Cursor.requery()标为QUOT;德precated"? [英] Why is Cursor.requery() marked "deprecated"?

查看:404
本文介绍了为什么Cursor.requery()标为QUOT;德precated"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cursor.requery()是在使用它来刷新ListView的内容的一种非常普遍的方法。但是,为什么这种方法标记为德precated?我不明白的API文档的原因非常清楚。

Cursor.requery() is a very common method while using it to refresh a ListView's content. But why is this method marked "deprecated"? I can't understand the reason on the API docs very clearly.

Cursor.requery()API:
http://developer.android.com/reference/android/database/Cursor html的#重新查询()

Cursor.requery() API: http://developer.android.com/reference/android/database/Cursor.html#requery()

任何人都可以请解释任何进一步的原因是什么?感谢:)

Can anyone please explain the reason any further? Thanks:)

推荐答案

我相信它做是因为新的装载机API 引入异步简化查询光标。

I believe it was done because new Loaders API was introduced to simplify querying Cursors asynchronously.

由于德precation票据上写着:

As deprecation note says

不要使用此。只是要求一个新的光标,这样就可以做到这一点异步和更新您的列表视图,一旦新的光标回来。

Don't use this. Just request a new cursor, so you can do this asynchronously and update your list view once the new cursor comes back.

这是我们应该使用。

更新

看来,它也可以脱的precation相关 Activity.startManaginCursor

It seems that it can also be related to deprecation of Activity.startManaginCursor:

startManagingCursor(光标C)
  这种方法去precated。使用带有LoaderManager而不是新的CursorLoader类;这也可在通过Android兼容包旧的平台。这种方法允许活动采取基于活动的生命周期管理给定的游标的生命周期对你的照顾。即,当在活动停止时它会自动调用停用()在给定的光标,并且当它被购买重新启动它会调用重新查询()为您服务。当活动被破坏,所有的管理光标会自动关闭。如果你的目标蜂窝或更高版本,可以考虑使用,而不是代替LoaderManager,可通过getLoaderManager()

startManagingCursor(Cursor c) This method is deprecated. Use the new CursorLoader class with LoaderManager instead; this is also available on older platforms through the Android compatibility package. This method allows the activity to take care of managing the given Cursor's lifecycle for you based on the activity's lifecycle. That is, when the activity is stopped it will automatically call deactivate() on the given Cursor, and when it is later restarted it will call requery() for you. When the activity is destroyed, all managed Cursors will be closed automatically. If you are targeting HONEYCOMB or later, consider instead using LoaderManager instead, available via getLoaderManager()

这篇关于为什么Cursor.requery()标为QUOT;德precated"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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