Reusing Code With Database Cursors

view story

http://stackoverflow.com – I find myself using this bit of code very often when I am retrieving the results from a Cursor SearchItem searchItem = new SearchItem(); searchItem.setId(cursor.getInt(cursor.getColumnIndex(COLUMN_NAME_ID))); searchItem.setOrigin(cursor.getString(cursor.getColumnIndex(COLUMN_NAME_ORIGIN))); searchItem.setDestination(cursor.getString(cursor.getColumnIndex(COLUMN_NAME_DESTINATION))); searchItem.setTimeStamp(cursor.getLong(cursor.getColumnIndex(COLUMN_NAME_TIMESTAMP))); Specifically this could be when I am using a CursorAdapter for a listview and in a DAO object. What would be a useful design (HowTos)