Skip to content

Accessing Fixture Data

Will edited this page Jun 21, 2018 · 4 revisions

Fixture Content Provider API

Android applications that have the appropriate permissions can read data from the fixture 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.

Support Library

Many of these functions are more easily accessible via the support library.

Prerequisites

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

Workflow

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.

Content URI Structure

The base and content authority of CommCare fixture provider requests is

content://org.commcare.dalvik.fixture/

Permissions

External applications should implement the permission

org.commcare.dalvik.provider.cases.read

in order to permit them to access case data through this API.

Available Providers

It will be helpful to refer to the internal FixtureDB XML provider when describing what information is made available by each provider

Fixture Name Listing

Provides a listing of the names and IDs of all the fixtures in the system.

  • content://org.commcare.dalvik.fixture/fixturedb/

Response content

column required
id yes
instance_id yes

Fixture Content

Returns the raw XML for a fixture with the given instance ID.

  • content://org.commcare.dalvik.fixture/fixturedb/[FIXTURE_ID]
column required
id yes
instance_id yes
content yes

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.