use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteAndTrigger.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteAndTrigger() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = 'Zach'");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
o.assertCursor().hasRow("alice", "Zach").hasRow("bob", "Zach").hasRow("eve", "Zach").isExhausted();
}
use of android.database.sqlite.SQLiteStatement in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteWithArgsAndTrigger.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteWithArgsAndTrigger() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.NAME + " = ?");
statement.bindString(1, "Zach");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).subscribe(o);
o.assertCursor().hasRow("alice", "Alice Allison").hasRow("bob", "Bob Bobberson").hasRow("eve", "Eve Evenson").isExhausted();
db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
o.assertCursor().hasRow("alice", "Zach").hasRow("bob", "Zach").hasRow("eve", "Zach").isExhausted();
}
use of android.database.sqlite.SQLiteStatement in project xUtils3 by wyouflf.
the class SqlInfo method buildStatement.
public SQLiteStatement buildStatement(SQLiteDatabase database) {
SQLiteStatement result = database.compileStatement(sql);
if (bindArgs != null) {
for (int i = 1; i < bindArgs.size() + 1; i++) {
KeyValue kv = bindArgs.get(i - 1);
Object value = ColumnUtils.convert2DbValueIfNeeded(kv.value);
if (value == null) {
result.bindNull(i);
} else {
ColumnConverter converter = ColumnConverterFactory.getColumnConverter(value.getClass());
ColumnDbType type = converter.getColumnDbType();
switch(type) {
case INTEGER:
result.bindLong(i, ((Number) value).longValue());
break;
case REAL:
result.bindDouble(i, ((Number) value).doubleValue());
break;
case TEXT:
result.bindString(i, value.toString());
break;
case BLOB:
result.bindBlob(i, (byte[]) value);
break;
default:
result.bindNull(i);
break;
}
// end switch
}
}
}
return result;
}
use of android.database.sqlite.SQLiteStatement in project squidb by yahoo.
the class SQLiteDatabaseAdapter method executeInsert.
@Override
public long executeInsert(String sql, Object[] bindArgs) {
SQLiteStatement statement = null;
try {
statement = db.compileStatement(sql);
SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs);
return statement.executeInsert();
} finally {
if (statement != null) {
statement.close();
}
}
}
use of android.database.sqlite.SQLiteStatement in project squidb by yahoo.
the class SQLiteDatabaseAdapter method executeUpdateDelete.
@Override
public int executeUpdateDelete(String sql, Object[] bindArgs) {
SQLiteStatement statement = null;
try {
statement = db.compileStatement(sql);
SquidCursorFactory.bindArgumentsToProgram(statement, bindArgs);
return statement.executeUpdateDelete();
} finally {
if (statement != null) {
statement.close();
}
}
}
Aggregations