0

As far as I know, Android listview shows the data virtualized (meaning it loads only the visible ones), so it is fast as it can be.

I have lots of data to get from the database (around 2000 but with lots of data in the fields), and I use ActiveAndroid in an AsyncTask to get them.

Unfortunately the AsyncTask with AA takes around 10-15 seconds to get the data so I see a progressbar during that time.

I get his by this code:

  LocalDateTime start=new LocalDateTime();
  LogCat("Start: "+start);
     elements = new Select().from(Data.class)
        .where("Data_Id=?", DataId).orderBy("Name ASC").execute();

  LogCat("Elements: "+elements .size());
  LocalDateTime end=new LocalDateTime();
  LogCat("End: "+end);
  LogCat("Time: "+(new Period(start,end).getSeconds()+" s"));

It would be good to accelerate the loading by somehow virtualizing the data retrieval.

I also use a search in the listview, that searches the whole list. So considering the would be also good.

What do you suggest? How should I proceed?

Nestor
  • 8,194
  • 7
  • 77
  • 156

1 Answers1

1

Pairing content provider and CursorLoader should solve your issue.

renam.antunes
  • 761
  • 1
  • 5
  • 11
  • I've never done this, I'll give it a try. Will it be effective, what do you reckon? – Nestor Jun 26 '14 at 07:33
  • I've been using Content Provider and cursor loader in all my apps for some time now and it handles pretty well a large data set. It's also pretty easy to filter. – renam.antunes Jun 28 '14 at 09:15
  • 1
    That sounds promising. Any chance that you can provide a sample of that? I've never done this, so some guidance would be very helpful. – Nestor Jun 28 '14 at 09:23