I need to display results from a SQL join in a ListView/ListActivity.
I've created a cursor:
Cursor cursor = db.rawQuery(LIST_JOIN_SQL, null);
and if I iterate through the cursor, the results are exactly what I expect. However when I try and use a SimpleCursorAdapter to display these results in a ListView I get a runtime exception because there is no column called ' id'.
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.item, cursor, FROM, TO);
Where FROM and TO are defined as:
private static String[] FROM = { "name", };
private static int[] TO = { R.id.name, };
Now I figure I'm probably using the wrong approach here, as it seems SimpleCursorAdapters aren't meant for displaying results of joins.
What approach would you recommend here? I'm restricted to using Android 1.6 APIs.