PersistenceService class

The PersistenceService class is a singleton which handles persistence of study runtime information to a SQLite database on the phone. Used to store information across app re-start on:

Studies are stored in the studies table and user tasks are stored in the task_queue table.

The path and filename format for the database is

~/carp.db

where ~ is the folder where SQLite places it database files.

On iOS, this is the NSDocumentsDirectory and the files can be accessed via the MacOS Finder.

On Android, Flutter files are stored in the databases directory, which is located in the data/data/<package_name>/databases/ folder. Files can be accessed via AndroidStudio.

Constructors

PersistenceService()
Get the singleton persistence layer.
factory

Properties

databaseName String
Full path and name of the database.
no setter
databasePath String
Path of the database.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
Close the persistence layer. After close is called, no deployment can be accessed or saved.
getAllStudies() Future<List<SmartphoneStudy>>
Get the list of all studies previously stored on this phone.
getStudy(String studyDeploymentId, String deviceRoleName) Future<SmartphoneStudy?>
Return the SmartphoneStudy with studyDeploymentId and deviceRoleName, or null when no such study is found.
getUserTasks([SmartphoneStudy? study]) Future<List<UserTaskSnapshot>>
Get the list of UserTaskSnapshot for study. If study is null, all user tasks are returned.
init() Future<void>
Initialize the persistence layer and the database.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeStudy(Study<PrimaryDeviceDeployment> study) Future<void>
Remove the study from local cache.
removeUserTasks([Study<PrimaryDeviceDeployment>? study]) Future<void>
Remove the list of user tasks for study. If study is null, all user tasks are removed.
saveStudy(SmartphoneStudy study) Future<bool>
Save the study persistently to a local cache. Returns true if successful.
saveUserTask(UserTask task) Future<void>
Update or delete a task queue entry.
toString() String
A string representation of this object.
inherited
updateStudy(SmartphoneStudy study) Future<bool>
Update the study persistently to a local cache. Returns true if successful.

Operators

operator ==(Object other) bool
The equality operator.
inherited