Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maximum file size allowed for files stored using File API

Hi, Is there any any limitation for size of file we can store using File API in Fitbit ionic ?

Best Answer
0 Votes
7 REPLIES 7

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.

Best Answer
0 Votes
So is that means that i can store an entire day sensor data from
Accelerometer and Gyroscope without breaking the application ?
Best Answer
0 Votes

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).

Peter McLennan
Gondwana Software
Best Answer
Thanks for the reply Catplace . May I know which type of file you have used
to store the data? From your reply I got a an idea that we can't store
these datas in a single file , Is it correct?
Best Answer
0 Votes

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().

 

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@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

 

Best Answer
0 Votes

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.

Peter McLennan
Gondwana Software
Best Answer
0 Votes