Wesley
Wesley

Reputation: 1009

Android - SQLite development

I am currently 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 ?

Sorry if my question is not very clear, I find this difficult to describe :-\ .

Thanks in advance for any tips.

Cheers Wesley

Upvotes: 0

Views: 78

Answers (1)

Dan Breslau
Dan Breslau

Reputation: 11522

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.

Upvotes: 1

Related Questions