I just used MatrixCursor to solve this exact problem. Take a look at this.
Edit: Sorry, I just looked at a question when I answered it. ContentProvider is the only way applications can share data. Application actions can use SharedPreferences for smaller data with the addition of a save.
Edit v2: here is the function that I used to populate the MatrixCursor for the request function of my ContentProvider. I use the predefined VIEW that I created, which returns a set of different values, and this sets the cursor with _ids, which I can pass to my ExpandableListView.
private Cursor getFactions() { MatrixCursor mc = new MatrixCursor(Model.Faction.PROJECTION); SQLiteDatabase db = dbHelper.getReadableDatabase(); Cursor c = db.query(MODELFACTION_TABLE_NAME, new String[] { Model.Faction.FACTION }, null, null, null, null, Model.Faction.FACTION + " ASC"); c.moveToFirst(); do { mc.addRow(new Object[] { c.getPosition(), c.getString(c.getColumnIndex(Model.Faction.FACTION))}); } while (c.moveToNext() && ! c.isAfterLast()); c.close(); db.close(); return mc; }
Kenneth cummins
source share