Example usage for android.database Cursor getInt

List of usage examples for android.database Cursor getInt

Introduction

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

Prototype

int getInt(int columnIndex);

Source Link

Document

Returns the value of the requested column as an int.

Usage

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

private static Integer readInteger(Cursor cursor, int index) {
    return (cursor.isNull(index) ? null : cursor.getInt(index));
}

From source file:Main.java

private static int processIntCursor(final Cursor cursor) {
    if (cursor.moveToFirst()) {
        return cursor.getInt(0);
    }/*from   w w  w.ja v a 2 s  .c o  m*/
    return 0;
}

From source file:Main.java

public static int getNbEspece(SQLiteDatabase db) {
    Cursor res = db.rawQuery("SELECT count(*) FROM espece", null);
    res.moveToFirst();//w w  w  . j a  v a2  s . co  m
    return res.getInt(0);
}

From source file:Main.java

public static int getNbTravail(SQLiteDatabase db) {
    Cursor res = db.rawQuery("SELECT count(*) FROM travail", null);
    res.moveToFirst();/* www  .  j a  va2  s. c  om*/
    return res.getInt(0);
}

From source file:Main.java

public static int getGroupCount(SQLiteDatabase db) {
    int count = 0;
    Cursor cursor = db.rawQuery("select count(*) from classlist", null);
    cursor.moveToNext();//from  w  w w.ja v  a  2s  .  co m
    count = cursor.getInt(0);
    cursor.close();
    return count;
}

From source file:Main.java

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

From source file:Main.java

public static int queryCount(SQLiteDatabase db, String tableName, String where, String[] whereArgs) {
    StringBuffer stringBuffer = new StringBuffer("select count(*) from ");
    stringBuffer.append(tableName);//from  ww  w . j ava  2 s  . co m
    if (where != null) {
        stringBuffer.append(" where ");
        stringBuffer.append(where);
    }
    Cursor cursor = db.rawQuery(stringBuffer.toString(), whereArgs);
    cursor.moveToFirst();
    int count = cursor.getInt(0);
    cursor.close();
    return count;
}

From source file:Main.java

public static int getGroupCount(SQLiteDatabase db) {
    int result = 0;
    //      SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READONLY);

    Cursor cursor = db.rawQuery("select count(*) from classlist;", null);
    cursor.moveToFirst();/* www  . j  ava 2s.c  om*/
    result = cursor.getInt(0);
    cursor.close();
    //      db.close();
    return result;

}

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);
}