因此,例如,如果我做一張像
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”的值呢?
uj5u.com熱心網友回復:
沒有getBoolean()方法,因為SQLite 中沒有布爾資料型別(盡管您可以將列定義為布林值)。
如果您已將列中的值存盤為0or 1,那么您可以像這樣檢索布林值:
String result;
boolean isImportant;
Cursor c...;
int titleIndex = c.getColumnIndex("title");
do
...
result = c.getString(titleIndex);
isImportant = (c.getInt(isImportantIndex) == 1);
...
while (c.moveToNext());
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/346781.html
標籤:爪哇 安卓 sqlite 布尔值 android-sqlite
