Get boolean from database using Android and SQLite

后端 未结 10 1553
情话喂你
情话喂你 2020-12-07 09:02

How can I obtain the value of a boolean field in an SQLite database on Android?

I usually use getString(), getInt(), etc. to get the values

10条回答
  •  忘掉有多难
    2020-12-07 09:59

    An implementation found at Ormlite Cursor also checks for Null which none of the other answers do.

       public boolean getBoolean(int columnIndex) {
            if (cursor.isNull(columnIndex) || cursor.getShort(columnIndex) == 0) {
                return false;
            } else {
                return true;
            }
        }
    

提交回复
热议问题