-
-
Notifications
You must be signed in to change notification settings - Fork 27
Accessing Case Data
Android applications that have the appropriate permissions can read data from the case database of the currently logged in CommCare user.
The android "permissions" and content provider API's are not sufficient to prevent unauthorized access to data in a number of circumstances. The manner in which this is protected by this API is still ongoing.
Many of these functions are more easily accessible via the support library.
In order to use this API, you'll need
- An application installed in CommCare
- A user logged into CommCare
- For the external application to implement the appropriate Android Permissions
Applications reading data from CommCare do so with an Android Content Provider.
Unlike a static content provider, CommCare's content provider requests should be considered transient. What data is available from CommCare depends on the logged in user and their current session data, since all CommCare data is encrypted at rest and is unavailable to the app while a user is not logged in. External applications should not store CommCare data in persistent storage unless properly encrypted.
Currently all CommCare content providers are Read Only. The databases cannot be manipulated externally.
The base and content authority of CommCare provider requests is
content://org.commcare.dalvik.case/
External applications should implement the permission
org.commcare.dalvik.provider.cases.read
in order to permit them to access case data through this API.
It will be helpful to refer to the internal CaseDB XML provider when describing what information is made available by each provider
Provides a listing of all cases in the system, along with their metadata. Essentially returns all of the named attributes for a case (case_type, date_opened, etc) in columns.
-
content://org.commcare.dalvik.case/casedb/case
content://org.commcare.dalvik.case/casedb/case/CASE_ID
Response content
column | required |
---|---|
case_id | yes |
case_type | yes |
owner_id | yes |
status | yes |
case_name | yes |
date_opened | yes |
last_modified | yes |
Returns the key/value pairs of all data for a specific case
content://org.commcare.dalvik.case/casedb/data/CASE_ID
column | required |
---|---|
case_id | yes |
datum_id | yes |
value | yes |
Returns all indices for a specific case
content://org.commcare.dalvik.case/casedb/index/CASE_ID
column | required |
---|---|
case_id | yes |
index_id | yes |
case_type | yes |
value | yes |
Returns all case attachments (still in flux) associated with a specific case.
content://org.commcare.dalvik.case/casedb/attachment/CASE_ID
column | required | description |
---|---|---|
case_id | yes | |
attachment_id | yes | |
attachment_type | no | (potential) Content type for the attachment |
value | yes | The body of the attachment (This will be very large and should be requested manually) |
Note that the value returned is the full body of the attachment, which means this API is only viable for communicating with attachments that are not particularly large, depending on the amount of memory on the device.