was just wondering, how can I obtain the value of a boolean field in a sqlite database in android?
I usually use getString()
getInt()
etc to get the values of my fields, but there does not seem to be a getBoolean()
method.
Any takers?
Kev
Source: Tips4all
If memory serves me right:
ReplyDeleteboolean value = cursor.getInt(boolean_column_index)>0;
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 SQLite3.
ReplyDeleteYou can also use
ReplyDeleteboolean value =cursor.getString(boolean_column_index).contains("true");
boolean value = (cursor.getInt(boolean_column_index) == 1);
ReplyDelete