On-device storage
Store measurements locally in a database or in files. No server needed.
On-device storage saves measurements in the app's private storage on the phone. It needs no server, no accounts and no network connection.
Data endpoint
Where data goes is set by a single setting in the study protocol, the data endpoint. On-device storage, CAWS and your own server differ only in this setting; the rest of the protocol (what to collect, and when) stays the same.
For on-device storage, use one of two endpoints:
| Endpoint | Saves data as | Use for |
|---|---|---|
SQLiteDataEndPoint() | A database on the phone | Apps that show the data back to the user, for example "your steps this week" |
FileDataEndPoint() | Zipped JSON text files | Handing the data to a researcher |
Configure the protocol
Start from the quickstart app and change the imports at the top of lib/main.dart to:
Smartphone exists in both packages; hide makes Dart use the one from carp_mobile_sensing.
Then, in _startSensing(), replace the protocol with the following steps.
Create the protocol and choose the endpoint
The
dataEndPointis the one setting that decides where data goes:Database Files Add the phone and the participant
The phone is the primary device that collects the data. The participant role represents the person using it.
Define what to collect, and when
ImmediateTriggerstarts collecting right away.BackgroundTaskkeeps collecting in the background.Start the client
This part is unchanged from the quickstart:
Tip
To switch between database and files, change only the endpoint in the first step. CAWS also uses an endpoint (CarpDataEndPoint), but there the protocol is set up in the portal and the app signs in. See CARP Web Services.
Retrieve the data
The data is stored in the app's private folder:
| Endpoint | Location |
|---|---|
| Database | carp-data, in the app's databases folder |
| Files | carp/deployments/<deployment id>/data/, in the app's documents folder |
To copy the data to your computer:
In Android Studio, open Device Explorer and go to data/data/<your app id>/. The database is in databases/, and the files are in app_flutter/carp/.
Add UIFileSharingEnabled = YES to Info.plist, connect the iPhone to a Mac, and open it in Finder → Files.
Moving to a server
On-device storage suits trying things out. For a study, you usually want data to arrive centrally without accessing each phone. For that, use CARP Web Services or your own server.
For more detail, see Data managers.