Skip to content

Settings

Global settings for CAMS: logging level, app info, time zone, a user ID, and the file paths used to store data on the phone.

A singleton, accessed as Settings(). Must be initialized with init before use, which SmartPhoneClientManager.configure does.

Supports:

Constructors

Settings

Settings()

Constants

CARP_CACHE_FILE_PATH

String const CARP_CACHE_FILE_PATH

Folder name for cached data under a deployment folder.

CARP_DATA_FILE_PATH

String const CARP_DATA_FILE_PATH

Folder name for data under a deployment folder.

CARP_DEPLOYMENT_FILE_PATH

String const CARP_DEPLOYMENT_FILE_PATH

Folder name for deployments under carpBasePath.

USER_ID_KEY

String const USER_ID_KEY

The preferences key under which userId is stored.

Properties

appName

String? get appName

The app name as displayed in the OS. CFBundleDisplayName on iOS, application/android:label on Android.

buildNumber

String? get buildNumber

The build number. CFBundleVersion on iOS, versionCode on Android.

carpBasePath

Future<String> get carpBasePath

The base path for storing all CARP related files on the form

<localApplicationPath>/carp

debugLevel

DebugLevel debugLevel
getter/setter pair

The global debug level setting.

See DebugLevel for valid debug level settings. Can be changed at runtime. Default is DebugLevel.warning.

initialized

bool get initialized

Has the setting been initialized via calling the init method?

localApplicationPath

Future<String> get localApplicationPath

Path to a directory where the application may place data that is user-generated (the app documents directory).

packageInfo

PackageInfo? get packageInfo

Package information for the app, from the package_info_plus plugin.

packageName

String? get packageName

The package name. PRODUCT_BUNDLE_IDENTIFIER on iOS, package on Android.

preferences

SharedPreferences? get preferences

A simple persistent store for simple data. Note that data is saved in plain format and should hence not be used for sensitive data.

Wraps NSUserDefaults (on iOS) and SharedPreferences (on Android).

timezone

String get timezone

The current time zone of this app.

Note that this is only set once when the app starts, and will not update if the user changes the time zone while the app is running. Defaults to Europe/Copenhagen if the time zone cannot be read.

userId

Future<String> get userId

A user ID that is:

  • unique
  • anonymous
  • persistent

This id is generated the first time this method is called and then stored on the phone in-between sessions, and will therefore be the same for the same app on the same phone. Requires init to have been called.

version

String? get version

The package version. CFBundleShortVersionString on iOS, versionName on Android.

Methods

getCacheBasePath

Future<String> getCacheBasePath(
  1. String studyDeploymentId
)

The base path for storing cached data for a deployment. The folder is created if it does not exist.

<localApplicationPath>/carp/deployments/<study_deployment_id>/cache

getDataBasePath

Future<String> getDataBasePath(
  1. String studyDeploymentId
)

The base path for storing data (e.g. data files and media files) for a deployment. The folder is created if it does not exist.

<localApplicationPath>/carp/deployments/<study_deployment_id>/data

getDeploymentBasePath

Future<String> getDeploymentBasePath(
  1. String studyDeploymentId
)

The base path for storing all deployment related files on the form

<localApplicationPath>/carp/deployments/<study_deployment_id>

init

Future<void> init()

Initializes settings. Must be called before using any settings.

Loads shared preferences and package info, creates carpBasePath, and reads the local timezone. Calling it again does nothing.