Get boolean from database using Android and SQLite

Kevin Bradshaw picture Kevin Bradshaw · Nov 3, 2010 · Viewed 82.6k times · Source

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.

Answer

Alex Orlov picture Alex Orlov · Nov 3, 2010

It is:

boolean value = cursor.getInt(boolean_column_index) > 0;