Question

I have a a database with more than 6000 entries. I am using this example http://eshyu.wordpress.com/2010/08/15/cursoradapter-with-alphabet-indexed-section-headers/ to display the contents. But now the activity isn't able to handle it. I get a ANR dialog every time. How do I efficiently handle this circumstance?

Was it helpful?

Solution

It doesn't make sense to go through each entry and ask the indexer on wich section that entry belongs to. In your case, the Indexer might be doing 6000 binary searches. Then puting that result in a map that will have below 30 entries and doing many overwrites.

It's also not a good idea to abuse the sectionToPosition Map to create a section starting postion.

A. You either prepare a table containing the stats, which would be the best way to handle so much data.

B. You can use the database to count number of entries for each section and build your own section starting pos map.

SELECT UPPER(SUBSTR(LTRIM(side_a), 1, 1)), COUNT(*) FROM cards GROUP BY 1 ORDER BY 1 ASC;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top