android, cursor returning boolean value?
Can an Android Cursor return a boolean value? I've looked at the docs and there was no info on it?
If not - 开发者_如何学JAVAthen is there an alternative way to get a boolean value from a SQLite table?
The android implementation of SQLite3 doesn't properly support boolean values. You will need to use integers set to 0 or 1 and write some code to convert that to a boolean e.g.
int x = cursor.getInt(...);
return x == 1;
Use enum type with values 'Y' and 'N' to represent the boolean value
Another way is just to pass as String rather than boolean and then parse it back to boolean:
int index = cursor.getColumnIndex(<key>);
String str = cursor.getString(index);
boolean bool = Boolean.parseBoolean(str);
精彩评论