简体   繁体   English

从Android中的Sqlite数据库加载大量数据

[英]Loading large amount of data from Sqlite database in Android

I'm writing an Android application that has different parts, including a dictionary. 我正在编写一个包含不同部分的Android应用程序,包括字典。 To implement a dictionary, I used the following technique: 为了实现字典,我使用了以下技术:

  1. Reading all words from Sqlite database and storing them in array list. 读取Sqlite数据库中的所有单词并将它们存储在数组列表中。 ("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. 从数据库中获取单词需要很长时间(大约50000个单词),有时它会给出“内存不足”异常。 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. 使用sql仅访问特定任务所需的信息。 Make your index on the lookup key for performance 在查找键上创建索引以获得性能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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