Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording stream data efficiently in Android

Tags:

android

stream

I am recording sensor data (accelerometer, compass, wifi) in Android in 5Hz frequence. I don't scan Wifi that frequently.

I am using text file. When I have 1000 data records in memory, I append them into a text file.

However this method seems quite slow. Will using a SQLite database be faster than plain text file?

like image 662
Yin Zhu Avatar asked Mar 05 '26 14:03

Yin Zhu


1 Answers

One approach may be to use a double buffered list, when one queue is full, start filling the next one and in the meantime have another thread write the full queue out to disk asynchronously then clear it (and then keep repeating).

You can also experiment to easily make it triple buffered or nth buffered if you like to make faster.

like image 90
Chanakya Avatar answered Mar 07 '26 06:03

Chanakya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!