Example usage for android.database Cursor isNull

List of usage examples for android.database Cursor isNull

Introduction

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

Prototype

boolean isNull(int columnIndex);

Source Link

Document

Returns true if the value in the indicated column is null.

Usage

From source file:Main.java

public static int intFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return -1;
    }/*from ww  w.j  a  va  2 s .  c  o  m*/
    return c.getInt(c.getColumnIndex(field));
}

From source file:Main.java

public static String stringFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return null;
    }//  w  w w . j  av a 2s  . c  om
    return c.getString(c.getColumnIndex(field));
}

From source file:Main.java

public static long longFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return -1l;
    }// ww  w  .j a  va2  s . c  o  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  w w .j  a va2  s.  c  om
    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 w  w.ja v a2 s .co m
    return c.getDouble(c.getColumnIndex(field));
}

From source file:Main.java

static Float getFloatOrNull(int columnIndex, Cursor cursor) {
    return cursor.isNull(columnIndex) ? null : cursor.getFloat(columnIndex);
}

From source file:Main.java

static Double getDoubleOrNull(int columnIndex, Cursor cursor) {
    return cursor.isNull(columnIndex) ? null : cursor.getDouble(columnIndex);
}

From source file:Main.java

static Long getLongOrNull(int columnIndex, Cursor cursor) {
    return cursor.isNull(columnIndex) ? null : cursor.getLong(columnIndex);
}

From source file:Main.java

static Integer getIntegerOrNull(int columnIndex, Cursor cursor) {
    return cursor.isNull(columnIndex) ? null : cursor.getInt(columnIndex);
}

From source file:Main.java

public static Date LoadDate(Cursor cursor, int index) {
    if (cursor.isNull(index)) {
        return null;
    }//from  w  w  w.  ja va2  s .c o m
    return new Date(cursor.getLong(index));
}