Cursor getColumnIndexOrThrow was added in API Level 1
public abstract int getColumnIndexOrThrow (String columnName)
Returns the zero-based index for the given column name, or throws IllegalArgumentException if the column doesn't exist. If you're not sure if a column will exist or not use getColumnIndex(String) and check for -1, which is more efficient than catching the exceptions.
Parameters: columnName the name of the target column.
Returns: the zero-based column index for the given column name
Throws: IllegalArgumentException if the column does not exist
1. Move the Cursor to the First Row of a Cursor named myCursor.
public abstract int getColumnIndexOrThrow (String columnName)
Returns the zero-based index for the given column name, or throws IllegalArgumentException if the column doesn't exist. If you're not sure if a column will exist or not use getColumnIndex(String) and check for -1, which is more efficient than catching the exceptions.
Parameters: columnName the name of the target column.
Returns: the zero-based column index for the given column name
Throws: IllegalArgumentException if the column does not exist
1. Move the Cursor to the First Row of a Cursor named myCursor.
try { String myString = cursor.getString(cursor.getColumnIndexOrThrow(android.provider.MediaStore.Audio.Media.DISPLAY_NAME));
} catch (IllegalArgumentException e ) {
e.printStackTrace();
}
http://developer.android.com/reference/android/database/Cursor.html#getColumnIndexOrThrow(java.lang.String)