get Boolean From Cursor - Android Database

Android examples for Database:Cursor Get

Description

get Boolean From Cursor

Demo Code


//package com.java2s;
import android.database.Cursor;

public class Main {
    private static final int COLUMN_NOT_EXISTS = -1;

    public static Boolean getBooleanFromCursor(Cursor cursor,
            String columnName) {/*from  w  w w  .  ja  v a  2s.  co  m*/
        int columnIndex;
        if ((columnIndex = cursor.getColumnIndex(columnName)) != COLUMN_NOT_EXISTS) {
            return (cursor.getInt(columnIndex) == 1) ? true : false;
        } else {
            return null;
        }
    }
}

Related Tutorials