简体   繁体   English

在 Android 中存储连续数据的最佳方式

[英]Best way to store continuous data in Android

In my Android application, there will be one service which will be generating some data (statistics) like (int, time, long, boolean).在我的 Android 应用程序中,将有一个服务会生成一些数据(统计数据),如(int、time、long、boolean)。

So my question is: what is the best and optimal way to save that data?所以我的问题是:保存该数据的最佳方式是什么? (Like in DB or file, etc.) (例如在数据库或文件等中)

Note: My app can't send data to any server, that data will be used in future by the application for some use case.注意:我的应用程序无法将数据发送到任何服务器,应用程序将来会在某些用例中使用该数据。

I think you should take a look at Shared Preferences.我认为你应该看看共享首选项。

Here Shared Preferences这里共享首选项

Depending on the type and use of data取决于数据的类型和用途

if the number of data is limited then you can use Shared Preference.如果数据数量有限,那么您可以使用共享首选项。

if your data contains bulk information like log or informations, you can use file.如果您的数据包含大量信息,如日志或信息,您可以使用 file. or if the field of data is limited you can also synchonize to file after storing to object.或者如果数据领域有限,您也可以在存储到对象后同步到文件。

IF the data has many fields or the amount is huge or there will be lots of add/edit/delete option then I think the best option is to use SqliteDatabase如果数据有很多字段或数量很大或者会有很多添加/编辑/删除选项,那么我认为最好的选择是使用 SqliteDatabase

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

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