03-18-2018 07:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-18-2018 07:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi there,
i want to create an app where the user can create and manage some exercises. These data has to be stored on the local device but I can't figure it out where I have do this. Is there any sqlite or nosql database on the device for storing such data on the Ionic/Versa.
Looking forward for help.
Best,
daniel
Answered! Go to the Best Answer.
Accepted Solutions
03-19-2018 22:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-19-2018 22:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
No, I don't recommend processing a lot of data on the device.
You can get the data off the device by sending it to the companion using the messaging API, then you can either manipulate it in the companion using your phone's processing power, or transfer it to your own server to manipulate.
03-18-2018 08:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-18-2018 08:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The File System API. Something like this:
import * as fs from "fs"; const DATA_TYPE = "cbor"; const DATA_FILE = "mydata.cbor";
let myData = loadData({ val: 0 });
saveData(myData);
function loadData(defaults) { try { return fs.readFileSync(DATA_FILE, DATA_TYPE); } catch (ex) { return defaults; } } function saveData(data) { fs.writeFileSync(DATA_FILE, data, DATA_TYPE); }

03-19-2018 12:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-19-2018 12:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi Jon,
Thanks for your fast reply.
So I have to build my own database with json lists? I'm planing some complex app with workouts, exercises and sets depending on each other. I think working, iterating and filtering over huge json files is'nt the best choice for performance. Do you have any idea for this, or do you think the small devices can handle it?

03-19-2018 22:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-19-2018 22:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
No, I don't recommend processing a lot of data on the device.
You can get the data off the device by sending it to the companion using the messaging API, then you can either manipulate it in the companion using your phone's processing power, or transfer it to your own server to manipulate.
03-24-2018 03:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-24-2018 03:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hey again @JonFitbit
If I have understood correctly, the "companion" only works if the user has the smartphone near by. But the idea of my app is, that you don't have to take your smartphone into the gym.
So here is my plan so far:
1. I create a small json database with workouts, exercises and sets on the device
2. the user creates his workout on a web app (server)
3. the last 10 workouts will be downloaded on the fitbit device (only names, timestamp and a list of max 20 exercises each workout)
4. now the user can add the sets (weight/reps) to each exercise of the choosen workout
5. after the workout is completed the device will trigger the sync via the companion. Now the sets will be uploaded to a webservice and deleted from the device (only the last 100 sets will stay for history)
So the main data of all workouts, exercises and sets are stored on the webserver. Only the latest data is synced to the device.
Do you think that could work? or any tips related to this?

03-24-2018 10:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
03-24-2018 10:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I know this is late, but you can store record layouts in a file. See this post ... you may find enough to help with your app.
https://community.fitbit.com/t5/SDK-Development/Replace-JSON-value/m-p/2533495/highlight/true#M2931

03-25-2018 23:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-25-2018 23:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
> No, I don't recommend processing a lot of data on the device.
Considering that you have just 64K bytes of the heap memory on the device, and you can only read the whole file... Nah, that doesn't sound like a good idea to process even a bit of data on the device.
If the FitBit team would increase the heap size, though, so it won't resemble an old good Commodore 64...

03-25-2018 23:24 - edited 03-25-2018 23:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-25-2018 23:24 - edited 03-25-2018 23:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Well, we could use overlays, of course. And then we could process hell a lot of data.
---
In the home computer era overlays were popular because the operating system and many of the computer systems it ran on lacked virtual memory and had very little RAM by current standards — the original IBM PChad between 16K and 64K depending on configuration. Overlays were a popular technique in Commodore BASIC to load graphics screens. In order to detect when an overlay was already loaded, a flag variable could be used.[6]
---
Do we really have to use overlays? 🙂 I really didn't expect such a technique will be useful for me again since I tried it last time in 90th :).

