sqlitestatement插入默认值android

时间:2015-08-27 05:59:18

标签: android sqlite

我试图插入sqlite,它的列的默认值为on。我正在使用SQLiteStatement来实现这一目标。我创建我的表格如下

public static void createTable(SQLiteDatabase db, boolean ifNotExists) 
{
    String constraint = ifNotExists? "IF NOT EXISTS ": "";
    db.execSQL("CREATE TABLE " + constraint + "\"DBUSER\" (" + 
            "\"BLOCKED\" INTEGER DEFAULT 0 ," + 
            "\"USERNAME\" TEXT," +
            "\"USER_ID\" TEXT PRIMARY KEY NOT NULL );");
}

我像这样插入

@Override
protected void bindValues(SQLiteStatement stmt, DBUser entity) {
    stmt.clearBindings();

    Boolean blocked = entity.getBlocked();
    if (blocked != null) {
        stmt.bindLong(1, blocked ? 1L: 0L);
    }

    String username = entity.getUsername();
    if (username != null) {
        stmt.bindString(2, username);
    }

    String userId = entity.getUserId();
    if (userId != null) {
        stmt.bindString(3, userId);
    }
}

问题是这样,我如何插入一个默认值为'被阻止'这个结构的价值?

提前致谢

0 个答案:

没有答案