[英]Is it OK to use Android's built-in SQLite storage for concurrent data storage?
I'm writing an Android application, which will consist of 我正在编写一个Android应用程序,其中包括
There will be 2 tables - SensorData
and Metrics
. 将有2个表
SensorData
和Metrics
。 Background service 1 will write to SensorData
. 后台服务1将写入
SensorData
。 Background service 2 will read from SensorData
and write to Metrics
. 后台服务2将从
SensorData
读取并写入Metrics
。 Background service 3 will remove rows from both tables. 后台服务3将从两个表中删除行。 The GUI activity will read from both tables.
GUI活动将从这两个表中读取。
I was thinking about how to implement a threadsafe storage for the sensor values and metrics. 我在考虑如何为传感器值和指标实现线程安全存储。
An obvious solution is to use the built-in SQLite database. 一个明显的解决方案是使用内置的SQLite数据库。
I have following questions: 我有以下问题:
long
and double
) twice per second? long
和double
)? SensorData
and background service 1 tries to write into the same table simultaneously) ? SensorData
上发出查询并且后台服务1尝试同时写入同一表时会发生什么情况)? SQLiteOpenHelper
as a singleton, you are thread-safe. SQLiteOpenHelper
作为单例使用,您是线程安全的。 SQLiteOpenHelper
handles the locking of the sqlite database (which is the sqlite mechanism to handle concurrent reads/writes). SQLiteOpenHelper
处理sqlite数据库的锁定(这是用于处理并发读取/写入的sqlite机制)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.