简体   繁体   English

在应用程序中拥有大量数据

[英]Having a lot of data in an application

I am planning on creating an android application sometime in the future in which I'll want it to display a lot of constant data on the screen. 我打算在将来的某个时候创建​​一个Android应用程序,我希望它能在屏幕上显示很多常量数据。

I'm not sure the best way to do this but I see two options: 我不确定最好的方法,但我看到两个选择:

  1. Storing the data within the code itself such as creating a constants class. 将数据存储在代码本身中,例如创建常量类。
  2. Using an embedded database to hold the data. 使用嵌入式数据库来保存数据。

I'm guessing option #2 is the best way? 我猜选项#2是最好的方法吗? But it just seems weird using a database if I'm not going to be doing any updating to the database, I would only be selecting. 但是如果我不打算对数据库进行任何更新,那么使用数据库似乎很奇怪,我只会选择。

The total amount of data that I need the application to display is maybe about 400 lines consisting of a string and two integers... 我需要应用程序显示的数据总量大约是400行,包括一个字符串和两个整数...

Is there a different way people use for such a situation that I don't know about? 人们使用不同的方式来处理我不知道的情况吗?

But it just seems weird using a database if I'm not going to be doing any updating to the database 但是如果我不打算对数据库进行任何更新,那么使用数据库似乎很奇怪

I am totally disagree with you. 我完全不同意你的意见。 Database is not only for updating. 数据库不仅用于更新。 It can be used as a better storage and definitely a best way for searching. 它可以用作更好的存储空间,绝对是搜索的最佳方式。 So as you want to preserve the data then it is definitely wise to use database. 因此,当您想保留数据时,使用数据库绝对是明智之举。

But if you want to handle data which will not persists , i,e you will use different datas for different run then you can use temporary class or other data structure to store data. 但是如果你想处理不会持续存在的数据,我会为不同的运行使用不同的数据,那么你可以使用临时类或其他数据结构来存储数据。

Finally, If you are planning to have portability then File storage is an easier solution. 最后,如果您计划具有可移植性,那么文件存储是一种更简单的解决方案。

SO you can see, that it totally depends on what you want. 所以你可以看到,这完全取决于你想要什么。

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

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