private ContentValues[] getContentValuesForThings(ThingResponseGroup2 response) { ContentValues[] thingValues = new ContentValues [response.getThing().size() + response.getUnprocessedThingKeyInfo().size()]; int idx = 0; for (Thing2 thing : response.getThing()) { ContentValues values = new ContentValues(); values.put("thing_id", thing.getThingId().getValue()); values.put("version_stamp", thing.getThingId().getVersionStamp()); values.put("thing_xml", XmlSerializer.safeWrite(thing)); thingValues[idx++] = values; } for (UnprocessedThingKeyInfo keys : response.getUnprocessedThingKeyInfo()) { ContentValues values = new ContentValues(); values.put("thing_id", keys.getThingId().getValue()); values.put("version_stamp", keys.getThingId().getVersionStamp()); thingValues[idx++] = values; } return thingValues; }
public AbstractThing getThingById(String thingId) { Cursor cursor = ctx.getContentResolver() .query( Uri.withAppendedPath( HVContentContract.CONTENT_URI, "records/" + record.getId() + "/things/" + thingId), new String[] {"thing_xml"}, null, null, null); AbstractThing data = null; if (cursor.moveToFirst()) { Thing2 thing = XmlSerializer.safeRead(Thing2.class, cursor.getString(0)); data = thing.getData(); } cursor.close(); return data; }