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 long longFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return -1l;
    }//  w  w  w  . j  a  va 2s .  co m
    return c.getLong(c.getColumnIndex(field));
}

From source file:Main.java

public static float floatFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return -1;
    }//from  w ww. j  a  v  a  2 s  . co  m
    return c.getFloat(c.getColumnIndex(field));
}

From source file:Main.java

public static double doubleFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return -1;
    }//  w  ww.j av a2s  .c  o m
    return c.getDouble(c.getColumnIndex(field));
}

From source file:Main.java

public static boolean boolFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return false;
    }/*from  w w w  .j  av a 2 s.  co  m*/
    int val = c.getInt(c.getColumnIndex(field));
    return (val > 0) ? true : false;
}

From source file:Main.java

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

From source file:Main.java

protected static byte[] getBlob(Cursor mCursor, String column) {
    return mCursor.getBlob(mCursor.getColumnIndex(column));
}

From source file:Main.java

public static Integer statusInt(Cursor c) {
    return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
}

From source file:Main.java

public static Integer reasonInt(Cursor c) {
    return c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
}

From source file:Main.java

public static boolean getBooleanFromDBInt(Cursor c, String columnName) {
    return c.getInt(c.getColumnIndex(columnName)) == 1;
}

From source file:Main.java

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