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

public static byte[] getBolbFromCursor(final Cursor cur, final String column) {
    final int idx = cur.getColumnIndex(column);
    return (idx == -1) ? null : cur.getBlob(idx);
}

From source file:Main.java

public static int getIntFromCursor(final Cursor cur, final String column) {
    final int idx = cur.getColumnIndex(column);
    return (idx == -1) ? 0 : cur.getInt(idx);
}

From source file:Main.java

public static String getStringFromCursor(final Cursor cur, final String column) {
    final int idx = cur.getColumnIndex(column);
    return (idx == -1) ? null : cur.getString(idx);
}

From source file:Main.java

public static long getLongFromCursor(final Cursor cur, final String column) {
    final int idx = cur.getColumnIndex(column);
    return (idx == -1) ? 0 : cur.getLong(idx);
}

From source file:Main.java

public static Long gLong(Cursor cursor, String columeName) {
    Long val = null;
    if (cursor.getColumnIndex(columeName) != -1) {
        val = cursor.getLong(cursor.getColumnIndex(columeName));
    }//from  w  w w  .  ja  v  a2s .c o m
    return val;
}

From source file:Main.java

public static String gText(Cursor cursor, String columeName) {
    String val = null;
    if (cursor.getColumnIndex(columeName) != -1) {
        val = cursor.getString(cursor.getColumnIndex(columeName));
    }//from   w w w  . java2 s.c  om
    return val;
}

From source file:Main.java

public static Boolean gBoolean(Cursor cursor, String columeName) {
    Boolean val = null;
    if (cursor.getColumnIndex(columeName) != -1) {
        val = cursor.getInt(cursor.getColumnIndex(columeName)) > 0;
    }//from w  w w.j a v  a2s  .  com
    return val;
}

From source file:Main.java

public static Integer gInt(Cursor cursor, String columeName) {
    Integer val = null;
    if (cursor.getColumnIndex(columeName) != -1) {
        val = cursor.getInt(cursor.getColumnIndex(columeName));
    }/*  w w  w  .j  a va  2s.co m*/
    return val;
}

From source file:Main.java

private static long getLong(final Cursor cursor, final String field, final long defValue) {
    if (cursor.getColumnIndex(field) >= 0) {
        return cursor.getLong(cursor.getColumnIndex(field));
    } else {//ww  w. j  a  v  a2 s.  c om
        return defValue;
    }
}

From source file:Main.java

public static int getInt(@NonNull Cursor cursor, @NonNull String columnName) {
    return cursor.getInt(cursor.getColumnIndex(columnName));
}