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:
- setting debug level - see debugLevel
- getting shared preferences - see preferences
- getting app info - see appName, packageName, version, buildNumber, and packageInfo
- generating a unique and anonymous user id - see userId
- getting the current timezone of the app - see timezone
- getting file paths for storing data - see localApplicationPath, carpBasePath, getDeploymentBasePath, getCacheBasePath, and getDataBasePath
Constructors
Settings
Constants
CARP_CACHE_FILE_PATH
Folder name for cached data under a deployment folder.
CARP_DATA_FILE_PATH
Folder name for data under a deployment folder.
CARP_DEPLOYMENT_FILE_PATH
Folder name for deployments under carpBasePath.
USER_ID_KEY
The preferences key under which userId is stored.
Properties
appName
The app name as displayed in the OS. CFBundleDisplayName on iOS, application/android:label on Android.
buildNumber
The build number. CFBundleVersion on iOS, versionCode on Android.
carpBasePath
The base path for storing all CARP related files on the form
<localApplicationPath>/carp
debugLevel
The global debug level setting.
See DebugLevel for valid debug level settings. Can be changed at runtime. Default is DebugLevel.warning.
initialized
Has the setting been initialized via calling the init method?
localApplicationPath
Path to a directory where the application may place data that is user-generated (the app documents directory).
packageInfo
Package information for the app, from the package_info_plus plugin.
packageName
The package name. PRODUCT_BUNDLE_IDENTIFIER on iOS, package on Android.
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
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
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
The package version. CFBundleShortVersionString on iOS, versionName on Android.
Methods
getCacheBasePath
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
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
The base path for storing all deployment related files on the form
<localApplicationPath>/carp/deployments/<study_deployment_id>
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.