Reputation: 668
I'm writing an Android application that has different parts, including a dictionary. To implement a dictionary, I used the following technique:
Reading all words from Sqlite database and storing them in array list. ("select * from vocabulary").
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
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