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

Is there a local database for storing data?

ANSWERED

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

Best Answer
1 BEST ANSWER

Accepted Solutions

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.

View best answer in original post

Best Answer
7 REPLIES 7

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); }

 

Best Answer
0 Votes

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?

Best Answer
0 Votes

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.

Best Answer

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?

Best Answer
0 Votes

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

Best Answer
0 Votes

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

Best Answer
0 Votes

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

Best Answer
0 Votes