My problem: My ListView resets its scroll position to the top whenever I update its contents through its (customized) SimpleCursorAdapter. I would like the ListView to main
Did the same in post execute of Async Task used following code worked for me
Cursor cursor = mDataHelper.getWritableDatabase().query(
DataContract.Incares.TABLE_NAME, // Table to Query
null, // all columns
null, // Columns for the "where" clause
null, // Values for the "where" clause
null, // columns to group by
null, // columns to filter by row groups
DataContract.Incares.UUID +" DESC" // sort order
);
CursorAdapter.swapCursor(cursor);
CursorAdapter.notifyDataSetChanged();
with CursorAdapter being a global variable
I've had a similar problem: My CursorAdapter reset the scroll position whenever the contents of the cursor changed.
I didn't realize that I actually did set a new list adapter each time the data changed. I thought the cursor himself would notify the adapter about changes to it's content but in my case it is the ContentProvider that triggers LoaderManager.LoaderCallbacks.onLoadFinished() in my ListFragment. In that callback I now use CursorAdapter.changeCursor() instead of creating a new adapter and everything works just fine.
I hope this helps solving your problem.