安卓如何从游标获取Bool(Java SQLite)
举个例子,如果我做一张像
db.execSQL("create table myTable (" + "id integer primary key autoincrement," + "title text," + "isImportant numeric" + ");");
想得到“头衔”,我想
String result;
Cursor c...;
int titleIndex = c.getColumnIndex("title");
do
...
result = c.getString(titleIndex);
...
while (c.moveToNext());
与c.getInt、c.getDoule等相同,但没有c.getBoolean。那么,如何从该表中获得“isImportant”的值呢
# 1 楼答案
没有
getBoolean()
方法,因为there is no Boolean data type in SQLite(尽管可以将列定义为布尔值)如果已将列中的值存储为
0
或1
,则可以检索如下布尔值: