简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM