1

I'm using an AsyncTaskLoader to load paginated data into an ArrayAdapter, but when I rotate the device, all of the previously fetched data will be cleared and the top of the list will now start at the last page that I fetched.

private int mPageNumber;

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
        int totalItemCount) {
    if (mPageNumber >= firstVisibleItem + visibleItemCount) {
        mPageNumber++;
        getLoaderManager().restartLoader(0, null, this);
    }
}

I don't really understand why this happens or the best way to handle it. Should I be caching the data, is that really necessary?

Daniel Pratt
  • 12,007
  • 2
  • 44
  • 61
  • http://stackoverflow.com/questions/5123407/losing-data-when-rotate-screen – Shayan Pourvatan Jun 23 '14 at 06:08
  • How am I supposed to save x number of items in the saved instance state, place them all back on top of the last loaded items, and then continue the pagination? That doesn't really seems like much of a solution. – user3766259 Jun 23 '14 at 06:11
  • why dont you download the data for a content provider, and creat the listview with a cursor adapter from that provider? – xanexpt Apr 14 '15 at 13:47

0 Answers0