Android: Best way to store large amount of sensor datas over long time

谁说我不能喝 提交于 2019-12-14 03:27:18

问题


I'm fairly new to Android-Development and I got a general question about How-To:

My App gets Sensor-Data from Step-Detector (Detected steps gets added up). Now I need to store those Steps (which will be a lot of Data).

The steps should be stored like this:
If Todays
steps are stored on per Hour basis.
Else
steps are stored on per Day basis

SharedPreferences falls out of this as it only stores KeyValues.

But can SQLite handle this? Or is there any other way? A future feature could be to sync those data with a Server. I mean this could end up in thousands of Entries, and the app will also support other large data sets which need to get stored in similar way.


回答1:


Try using Realm noSql database for it. The point is, you can save entire database on sd card as separate file for each day and process it later. It is native and work very fast with large amount of data. You can process all your readings later on - open database, transform readings (perhaps interpolate values for older to shring data in size) and then upload it to the cloud and delete database file. But, anyways, a database is just implementation details, consider abstracting out all your operations so you can replace db later on. As far as I know, sqLite stores all tables in a single file, so you will need column for a date and all records will be stored in single table. Realm is more flexible for this task.




回答2:


SQL Lite can be used , it will be there as long as your application exist in the device, however if you want you can use Cloud Service, Azure provides simple and easy to use App Service , which have easy tables , in which you can directly call the APIs and internally it takes care of making connection and inserting the data into table.You can use Free Tier of App Service to test the concept.



来源:https://stackoverflow.com/questions/42879074/android-best-way-to-store-large-amount-of-sensor-datas-over-long-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!