/** * Lookup the indicies of the each column name and return them in an array. * * @param cursor the cursor that contains the columns * @param columnNames the array of names to lookup * @return an array of column indices */ private int[] buildColumnIndiciesArray(Cursor cursor, String[] columnNames) { int[] columns = new int[columnNames.length]; for (int i = 0; i < columnNames.length; i++) { columns[i] = cursor.getColumnIndexOrThrow(columnNames[i]); } return columns; }
/** * Reads a Double out of a column in a Cursor and writes it to a ContentValues. Adds nothing to * the ContentValues if the column isn't present or if its value is null. * * @param cursor The cursor to read from * @param column The column to read * @param values The {@link ContentValues} to put the value into */ public static void cursorDoubleToContentValuesIfPresent( Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getDouble(index)); } }
public static void cursorStringToInsertHelper(Cursor paramCursor, String paramString, InsertHelper paramInsertHelper, int paramInt) { paramInsertHelper.bind(paramInt, paramCursor.getString(paramCursor.getColumnIndexOrThrow(paramString))); }
public static void cursorStringToContentValues(Cursor paramCursor, String paramString1, ContentValues paramContentValues, String paramString2) { paramContentValues.put(paramString2, paramCursor.getString(paramCursor.getColumnIndexOrThrow(paramString1))); }
/** * Reads a String out of a field in a Cursor and writes it to a Map. * * @param cursor The cursor to read from * @param field The TEXT field to read * @param values The {@link ContentValues} to put the value into, with the field as the key * @param key The key to store the value with in the map */ public static void cursorStringToContentValues( Cursor cursor, String field, ContentValues values, String key) { values.put(key, cursor.getString(cursor.getColumnIndexOrThrow(field))); }
/** * Reads a String out of a field in a Cursor and writes it to an InsertHelper. * * @param cursor The cursor to read from * @param field The TEXT field to read * @param inserter The InsertHelper to bind into * @param index the index of the bind entry in the InsertHelper */ public static void cursorStringToInsertHelper( Cursor cursor, String field, InsertHelper inserter, int index) { inserter.bind(index, cursor.getString(cursor.getColumnIndexOrThrow(field))); }