Question

I'm developing an app that uses an internal sqlite database. The MainActivity contains a Fragment.This fragment has a ViewPager which contains other 3 fragments, each of these 3 fragments has a ListView in it. when you click an item of the list, a second Activity is opened containing another ViewPager that has fragments showing the complete details(a bitmap and Strings) of each list item.

My question is, what would be better for performance ?

  1. To make constant calls to the database each time the user scrolls through the detail fragments(ViewPager).

  2. Make only three calls to the database (one for each listview in the mainActivity), to create 3 ArrayList of objects and keep them in memory. The list could have lots of items.

  3. Is there something else I'm not considering ?

Was it helpful?

Solution

3. Is there something else I'm not considering ?

Yes, use ViewPager.setOffscreenPageLimit instead.

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