Recording stream data efficiently in Android

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?


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.