Android: Handling very large data sets in ContentProvider to avoid memory limits

前端 未结 2 2015
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 13:41

I am using a ContentProvider to query a database and return a Cursor that is used in a CursorLoader:

ItemsActivity:

         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 14:00

    I agree with CL that you shouldn't do this. This isn't a good idea on mobile and neither is it on desktops. Who wants to scroll 30000 elements? What for? Most probably the user is looking for one result only, isn't she? So provide an easy way to filter the result set.

    Until the result set is small enough to be actually usable (this is not the same as the list scrolling fine - it's probably a much smaller number of results) you simply should display the total number of hits for the current query and maybe some elements as a sample to the user. The user must filter the list to get to actually usable sizes.

提交回复
热议问题