I supply a cursor to a ListActivity like this: My question is how/when should I close my cursor when I am done?
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
if (cursor != null) {
mCursorAdapter = new CursorAdapter(this, cursor);
setListAdapter(mCursorAdapter);
}
Thank you.
onDestroy(). Sooner, if you are specifically clearing out the list sooner than that. Or, callstartManagingCursor(cursor), and Android will close it for you, when it is safe to do so.