List of usage examples for android.database Cursor getColumnIndexOrThrow
int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException;
From source file:com.google.android.demos.jamendo.widget.SearchAdapter.java
private void bindTextView(View view, Cursor cursor, int viewId, String columnName) { TextView textView = (TextView) view.findViewById(viewId); int columnIndex = cursor.getColumnIndexOrThrow(columnName); textView.setText(cursor.getString(columnIndex)); }
From source file:com.dabay6.android.apps.carlog.adapters.ModelCursorAdapter.java
/** * {@inheritDoc}/*from w w w . jav a 2 s .co m*/ */ @Override public CharSequence convertToString(final Cursor cursor) { final int columnIndex = cursor.getColumnIndexOrThrow(Model.Columns.MODEL_NAME.getName()); return cursor.getString(columnIndex); }
From source file:com.bydavy.card.receipts.ReceiptListAdapter.java
private void cacheColumnIndex(Cursor c) { if (c != null) { mColumnId = c.getColumnIndexOrThrow(Receipts._ID); mColumnShop = c.getColumnIndexOrThrow(Receipts.COLUMN_NAME_SHOP); mColumnNote = c.getColumnIndexOrThrow(Receipts.COLUMN_NAME_NOTE); mColumnTotal = c.getColumnIndexOrThrow(Receipts.COLUMN_NAME_TOTAL); mColumnDate = c.getColumnIndexOrThrow(Receipts.COLUMN_NAME_DATE); mColumnVerified = c.getColumnIndexOrThrow(Receipts.COLUMN_NAME_VERIFIED); }//from ww w. ja va 2 s .c o m }
From source file:com.google.android.demos.jamendo.widget.SearchAdapter.java
private void bindImageView(View view, Cursor cursor, int viewId, String columnName) { ImageView imageView = (ImageView) view.findViewById(viewId); int columnIndex = cursor.getColumnIndexOrThrow(columnName); String url = cursor.getString(columnIndex); switch (mImageLoader.bind(this, imageView, url)) { case LOADING: case ERROR:/*from w w w. j a v a 2 s . c om*/ imageView.setImageDrawable(null); } }
From source file:android.database.DatabaseUtils.java
/** * Reads a String 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//from w w w . j a va2s .com * @param values The {@link ContentValues} to put the value into */ public static void cursorStringToContentValuesIfPresent(Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getString(index)); } }
From source file:android.database.DatabaseUtils.java
/** * Reads a Long 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/* w ww . j av a 2 s. c o m*/ * @param values The {@link ContentValues} to put the value into */ public static void cursorLongToContentValuesIfPresent(Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getLong(index)); } }
From source file:android.database.DatabaseUtils.java
/** * Reads a Short 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//from w w w. j ava 2 s . com * @param values The {@link ContentValues} to put the value into */ public static void cursorShortToContentValuesIfPresent(Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getShort(index)); } }
From source file:android.database.DatabaseUtils.java
/** * Reads a Integer 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// ww w. j a v a 2s . com * @param values The {@link ContentValues} to put the value into */ public static void cursorIntToContentValuesIfPresent(Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getInt(index)); } }
From source file:android.database.DatabaseUtils.java
/** * Reads a Float 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//from w w w . j av a2s. c om * @param values The {@link ContentValues} to put the value into */ public static void cursorFloatToContentValuesIfPresent(Cursor cursor, ContentValues values, String column) { final int index = cursor.getColumnIndexOrThrow(column); if (!cursor.isNull(index)) { values.put(column, cursor.getFloat(index)); } }
From source file:android.database.DatabaseUtils.java
/** * 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/*w ww. j av a 2 s . c o m*/ * @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)); } }