views:

29

answers:

1

I've been looking at examples of CursorAdapter implementations to make sure I'm doing everything right.

One thing I've noticed that I'm not doing is calling changeCursor(null) on my CursorAdapter in the Activity's onStop() handler.

mAdapter.changeCursor(null);

What is the purpose of this? I'm willing to do it if there's a good reason, but I hate navigating to another Activity, backing up to this Activity, and seeing a blank screen for a second until a new Cursor is queried.

+1  A: 

What is the purpose of this?

As Falmarri suggests, it is so your Cursor is no longer tied to the adapter, and so you can close() the Cursor without problems. IMHO, it is not necessary to call changeCursor(null) in onStop(). Particularly if you manage your Cursor (startManagingCursor() on Activity), Android will take care of the Cursor for you with respect to the activity lifecycle.

CommonsWare
Thank you for the clarification. I am not having the Activity manage the Cursor. I've essentially copied this: http://apps-for-android.googlecode.com/svn-history/r77/trunk/RingsExtended/src/com/example/android/rings_extended/MusicPicker.java
Andrew