Example usage for android.database Cursor getColumnIndex

List of usage examples for android.database Cursor getColumnIndex

Introduction

In this page you can find the example usage for android.database Cursor getColumnIndex.

Prototype

int getColumnIndex(String columnName);

Source Link

Document

Returns the zero-based index for the given column name, or -1 if the column doesn't exist.

Usage

From source file:Main.java

protected static float getFloat(Cursor mCursor, String column) {
    return mCursor.getFloat(mCursor.getColumnIndex(column));
}

From source file:Main.java

public static String getString(Cursor cursor, String column) {
    return cursor.getString(cursor.getColumnIndex(column));
}

From source file:Main.java

protected static String getString(Cursor mCursor, String column) {
    return mCursor.getString(mCursor.getColumnIndex(column));
}

From source file:Main.java

private static int getIntFromCursor(Cursor cursor, String columnName) {
    return cursor.getInt(cursor.getColumnIndex(columnName));
}

From source file:Main.java

public static long getLongOnCursor(Cursor cursor, String columnName) {
    return cursor.getLong(cursor.getColumnIndex(columnName));
}

From source file:Main.java

public static boolean getBoolean(Cursor cursor, String columnName) {
    return cursor.getInt(cursor.getColumnIndex(columnName)) == 1 ? true : false;
}

From source file:Main.java

public static String getStringOnCursor(Cursor cursor, String columnName) {
    return cursor.getString(cursor.getColumnIndex(columnName));
}

From source file:Main.java

private static String getStringFromCursor(Cursor cursor, String columnName) {
    return cursor.getString(cursor.getColumnIndex(columnName));
}

From source file:Main.java

public static Uri getMediaUri(Cursor cursor, Uri uri) {
    String id = cursor.getString(cursor.getColumnIndex(MediaColumns._ID));
    return Uri.withAppendedPath(uri, id);
}

From source file:Main.java

/**
 * Checks if it is a valid column within the cursor data
 *
 * @param cursor// w ww .jav a2s .co  m
 * @param columnName
 * @return
 */
private static boolean isValidColumn(Cursor cursor, String columnName) {
    int x = cursor.getColumnIndex(columnName);
    if (x < 0) {
        //No column matches that, it doesn't exist
        return false;
    } else {
        //A column matches that, it exists
        return true;
    }
}