1

我发现了两种不同的实现方法AsyncQueryHandler

  1. stackOverFlow 上的一个
  2. 第二个在这个博客上。

在第一种方法中,我们没有从子类化,AsyncQueryHandler而在第二种方法中,我们手动关闭cursor.

我想知道

AsyncQueryHandler处理cursor?或者我们必须手动关闭它(如第二种方法中所做的那样)?

4

1 回答 1

0

AsyncQueryHandler, as seen in the source, does not handle any returned Cursor that is returned in onQueryComplete. Note that any of the other ContentProvider methods (insert, update, delete) do not return a Cursor and are therefore much easier to understand.

Generally, if you are going to query a ContentProvider and use the resulting data (to say, fill a ListView), you would want to use Loaders along with a CursorLoader. These classes are available in the support library and provide a much more robust framework (including automatically reloading data if the underlying ContentProvider data changes) for managing queries.

于 2013-04-27T05:15:31.800 回答