Farid Ala
Farid Ala

Reputation: 668

Loading large amount of data from Sqlite database in Android

I'm writing an Android application that has different parts, including a dictionary. To implement a dictionary, I used the following technique:

  1. Reading all words from Sqlite database and storing them in array list. ("select * from vocabulary").

  2. Searching for definitions, using a simple binary search on array list.

It takes too long to fetch words from database (about 50000 words) and some times it gives "out of memory" exception. However after loading data, it works very rapidly to find definition of words. Would you please guide me how I can implement the dictionary?

Upvotes: 1

Views: 1629

Answers (1)

Derek Litz
Derek Litz

Reputation: 10897

Databases are typically meant for quick out of memory access (disk access). Taking your entire database and putting it into memory doesn't make much sense. Use sql to access only the information you need for the particular task. Make your index on the lookup key for performance

Upvotes: 4

Related Questions