Loading...

Room: Persistently append objects to a List


Background: I'm collecting data from an external sensor (breathing sensor strapped around your chest) that outputs data every second. This collection occurs in the background and will not be shown to the user until the session has completed.

Structure: I have a record structure that exists of an id, name, created_at, updated_at and samples - the latter attribute is a list (I've used TypeConvert to convert the list of objects to JSON) of a custom object named sample that contains: id, timestamp and value

Motivation: I have to frequently append new data to the list due to persistently store the data as well as reducing the memory usage on the device (I get samples of data every second that will span over 8-10 hours).

Problem: How do I append to the list (samples) without having to fetch the whole entry into memory, append the data and then update the entry? Is there a solution to just target the field and append the data directly?

- - Source
comments powered by Disqus