Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get boolean from database using Android and SQLite

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 of my fields, but there does not seem to be a getBoolean() method.

like image 403
Kevin Bradshaw Avatar asked Oct 01 '22 03:10

Kevin Bradshaw


2 Answers

It is:

boolean value = cursor.getInt(boolean_column_index) > 0;
like image 360
Alex Orlov Avatar answered Oct 17 '22 11:10

Alex Orlov


There is no bool data type in SQLite. Use an int that you fix to 0 or 1 to achieve that effect. See the datatypes reference on SQLite 3.0.

like image 46
NG. Avatar answered Oct 17 '22 11:10

NG.