SimpleCursorAdapter的老构造德precated ..真的吗?SimpleCursorAdapter、precated

2023-09-04 13:15:21 作者:岛是海心上的疤

Here它说, SimpleCursorAdapter 的API级别1构造德precated和使用 LoaderManager CursorLoader 推荐。

Here it says that SimpleCursorAdapter's API level 1 constructor is deprecated and the use of LoaderManager and CursorLoader is recommended.

不过,潜心钻研 LoaderManager CursorLoader 的使用,我发现this例子是扩展了 ListFragment (片段本身的延伸,我想),我们创建了一个 CursorLoader 内部类中。一切似乎确定,除了一个事实,即 CursorLoader 需要乌里作为参数。因此,这意味着我需要创建一个的ContentProvider 以访问我的数据库。

But delving into the LoaderManager and CursorLoader's use I found this example where inside an inner class that extends a ListFragment (an extension of Fragment itself I suppose) we create a CursorLoader. Everything seems ok, except for the fact that CursorLoader takes a Uri as an argument. So this implies that I need to create a ContentProvider to get access to my database.

我必须承认,它看起来像一个矫枉过正必须经历这一切只是为了创建一个简单的的ListView 与项目从数据库的到来。特别是如果我不打算让我提供给其他应用程序的数据库的数据和内容提供商的主要目的是为了做到这一点。

I must confess it looks like an overkill to have to go through all of this just to create a simple ListView with items coming from a database. Specially if I have no intention of making my database data available to other apps, and the main purpose of a content provider is to do that.

那么,这真的值得吗?

So is it really worth it?

特别是像我所在的内容要取出的情况下,很可能将是小的。我认真考​​虑做旧的方式,你看怎么样?

Especially in cases like mine where the content to be fetched is likely going to be small. I'm seriously considering doing it the old way, what do you say?

推荐答案

我写href="https://gist.github.com/1217628" rel="nofollow">简单CursorLoader 一个