0

I am developing an Android app that works with an SQLite database locally. I am wondering what the best way is to load data from the database.

the database would contain about 3 tables that would total up to about 500 rows. What would be the best option in this case:

  • Load all data on startup to fill the java model for use in the application.
  • Load only data that is needed in each screen. This probably requires db calls on nearly each screen load but will need less memory. If this is the best solution, how do you handle this situation ? If you would open a view, you would have to query the db since not everything is pre-loaded. But if you would open it again afterwards, you would have to have some kind of 'caching' mechanism to detect if it's already pre-loaded?
desertnaut
60.8k32 gold badges155 silver badges183 bronze badges
asked Sep 26, 2013 at 14:56
2
  • 2
    stackoverflow.com/questions/371538/… Commented Sep 26, 2013 at 15:00
  • mix both. use an LRU cache with your database. Commented Sep 26, 2013 at 15:25

1 Answer 1

1

What would you do if your database grew to 5,000 rows? 50,000?

Premature optimization is one of the leading causes of poor design. In my (relatively limited) experience, SQLite database queries are fast enough. Try loading your data on demand, as is fairly standard practice, and see if your program runs quickly enough.

answered Sep 26, 2013 at 15:01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.