简体   繁体   English

在Android中存储少量数据

[英]Storing little amount of data in android

There are 2000 records of data. 有2000条数据记录。 The only thing I want to do with records is getting values(no removing or editing). 我想对记录做的唯一一件事就是获取值(不删除或编辑)。 Data is not hard-structured. 数据不是硬结构的。 I can treat data as key-value storage. 我可以将数据视为键值存储。 I'm going to init data from file (about 1mb) when app starts and then keep it in array or hashtable. 当应用启动时,我将从文件(大约1mb)中初始化数据,然后将其保留在数组或哈希表中。 Is that a good idea to store it in memory? 将其存储在内存中是个好主意吗?

I think is not good idea to have that data in memory, because you will have to keep the data in every android lifecycle step, although you can store the data in key-value i think you should store it in a database and access it throught a content provider. 我认为将这些数据存储在内存中不是一个好主意,因为您必须将数据保留在每个Android生命周期步骤中,尽管您可以将数据存储为键值,但我认为您应该将其存储在数据库中并通过它进行访问内容提供商。

Content Provider Basics: http://developer.android.com/guide/topics/providers/content-provider-basics.html 内容提供商基础: http//developer.android.com/guide/topics/providers/content-provider-basics.html

Using large amount of data, best practice is sqlite 使用大量数据,最佳实践是sqlite

Here is very good SQLite tutorial . 这是很好的SQLite 教程

another tuorial http://www.screaming-penguin.com/node/7742 另一个葬礼http://www.screaming-penguin.com/node/7742

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

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