Hi Guys,
I am attempting to create an Android mobile application that can be used to generate and display graphs and charts from CommCare application data stored on the mobile device.
I am trying to query a CommCare app data repository by using an Android ContentResolver.
Here is the code I have written to query the database:
-------------------------------
private static final String REPORT_INSTANCE_ID = "commcare:reports";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
selectFixture(REPORT_INSTANCE_ID);
} catch (Exception e) {
e.printStackTrace();
}
}
private void selectFixture(String fixtureId) throws Exception {
String reportXml = getReportXml(fixtureId);
Document document = getXmlDom(reportXml);
renderDocumentToGraph(document);
}
private String getReportXml(String fixtureId) {
ContentResolver cr = getContentResolver();
Cursor c = cr.query(Uri.parse("content://org.commcare.dalvik.case/fixturedb/" + fixtureId), null, null, null, null);
if (!c.moveToFirst()) {
return null;
}
return c.getString(c.getColumnIndex("content"));
}
-------------------------------
I am not certain if the Uri I am using is correct but the Uri was recommended by a Dimagi employee. However, the ContentResolver always returns NULL when I perform a query.
Can anyone advise me on what I am doing wrong or assist me in resolving this issue.
Thank you
Faizel