11-27-2018 23:42
11-27-2018 23:42
Hi, Is there any any limitation for size of file we can store using File API in Fitbit ionic ?
11-28-2018 12:44
11-28-2018 12:44
You have 10mb in the file system including your app and its resources, but I don't think there's an individual file size limit.
11-28-2018 22:14
11-28-2018 22:14
11-28-2018 22:22
11-28-2018 22:22
I've managed to store a whole day's data comprising energy, distance, steps, active minutes, altitude and heart-rate, sampled at 15-second intervals. This took me six files of 11,522 bytes each (with each value stored as an Int16 to conserve app memory).
11-28-2018 22:31
11-28-2018 22:31
11-28-2018 22:39
11-28-2018 22:39
Sorry, I mislead you. One large file should be fine, so long as you don't try to get it all in memory at once.
I used Int16Array for in-memory buffers. You can read and write these to binary files using, eg, writeSync().
12-01-2018 12:36
12-01-2018 12:36
@Gondwana After reading, how to remove the corresponding buffer from the binary file?
or is there any possibility to remove data from the binary file?
thanks
12-01-2018 12:54
12-01-2018 12:54
I don't think you can truncate a file, but you can write new data to any location within it. I use this method, and keep track of which bits of the file contain valid data using in-memory variables (carefully saved and restored when necessary). You could also write 'invalid'/'empty' sentinel values to the file.
This is perhaps inefficient, but I've found that it's a lot quicker to create a fixed-length file and then use it like an array, reading and writing data in blocks whenever possible. Iterating through hundreds of values in JS code can get your app killed for unresponsiveness (although you could put timeouts in slow code, but then you have to deal with possible events while your data is in an indeterminant state).
In my case, I knew that I'd want a value for every 15 seconds, so I just use files that contain exactly 24*60*60/15 Int16s. To avoid having to create and initialise such files on the device (which is slow), my app ships with a pre-created empty file of that length. Duplicating it is quick because it can be done in a few file system calls; no looping is required.