本文整理匯總了Java中android.database.sqlite.SQLiteStatement.bindBlob方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteStatement.bindBlob方法的具體用法?Java SQLiteStatement.bindBlob怎麽用?Java SQLiteStatement.bindBlob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.database.sqlite.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.bindBlob方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveBinary
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
public boolean saveBinary(Condition query, String name, byte[] data, int offset, int length) throws DBException
{
SQLiteStatement statement = null;
try
{
SqlUtil.WhereSQL whereSQL = SqlUtil.toUpdate(tableName, checkCondition(query), name, true);
statement = db.compileStatement(whereSQL.sql);
byte[] bs = new byte[length];
System.arraycopy(data, offset, bs, 0, length);
statement.bindBlob(1, bs);
Object[] args = whereSQL.args;
for (int i = 0; i < args.length; i++)
{
bind(i + 2, args[i], statement);
}
return true;
} catch (Exception e)
{
throw new DBException(e);
} finally
{
close(statement);
}
}
示例2: buildStatement
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
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;
}
示例3: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, SimpleEntityNotNull entity) {
stmt.clearBindings();
stmt.bindLong(1, entity.getId());
stmt.bindLong(2, entity.getSimpleBoolean() ? 1L: 0L);
stmt.bindLong(3, entity.getSimpleByte());
stmt.bindLong(4, entity.getSimpleShort());
stmt.bindLong(5, entity.getSimpleInt());
stmt.bindLong(6, entity.getSimpleLong());
stmt.bindDouble(7, entity.getSimpleFloat());
stmt.bindDouble(8, entity.getSimpleDouble());
stmt.bindString(9, entity.getSimpleString());
stmt.bindBlob(10, entity.getSimpleByteArray());
}
示例4: createFiles
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
private void createFiles(SQLiteDatabase db) {
mFileNames = new String[mFiles];
byte[] rawData = new byte[mFileSize+mFiles];
Random random = new Random();
random.nextBytes(rawData);
ByteArrayOutputStream[] streams = new ByteArrayOutputStream[mFiles];
for (int i = 0; i < mFiles; i++) {
streams[i] = new ByteArrayOutputStream(mFileSize);
streams[i].write(rawData, i, mFileSize);
mFileNames[i] = String.valueOf(i);
}
SQLiteStatement insert = db.compileStatement("INSERT INTO files (filename, data) VALUES (?, ?)");
for (int i = 0; i < mFiles; i++) {
insert.bindString(1, mFileNames[i]);
insert.bindBlob(2, streams[i].toByteArray());
insert.execute();
}
}
示例5: Picture_Insert
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
public void Picture_Insert(String country, String city, String latitude, String longitude,
byte[] thumbnail, String mainImg) {
// open read and write database
SQLiteDatabase db = getWritableDatabase();
// execute insert query
SQLiteStatement p = db.compileStatement("INSERT INTO Picture values(?,?,?,?,?,?,?);");
p.bindNull(1);
p.bindString(2, country);
p.bindString(3, city);
p.bindString(4, latitude);
p.bindString(5, longitude);
p.bindBlob(6, thumbnail);
p.bindString(7, mainImg);
p.execute();
db.close();
Log.d("Database :", "INSERT Complete!");
}
示例6: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, TestEntity entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
stmt.bindLong(2, entity.getSimpleInt());
Integer simpleInteger = entity.getSimpleInteger();
if (simpleInteger != null) {
stmt.bindLong(3, simpleInteger);
}
stmt.bindString(4, entity.getSimpleStringNotNull());
String simpleString = entity.getSimpleString();
if (simpleString != null) {
stmt.bindString(5, simpleString);
}
String indexedString = entity.getIndexedString();
if (indexedString != null) {
stmt.bindString(6, indexedString);
}
String indexedStringAscUnique = entity.getIndexedStringAscUnique();
if (indexedStringAscUnique != null) {
stmt.bindString(7, indexedStringAscUnique);
}
java.util.Date simpleDate = entity.getSimpleDate();
if (simpleDate != null) {
stmt.bindLong(8, simpleDate.getTime());
}
Boolean simpleBoolean = entity.getSimpleBoolean();
if (simpleBoolean != null) {
stmt.bindLong(9, simpleBoolean ? 1L: 0L);
}
byte[] simpleByteArray = entity.getSimpleByteArray();
if (simpleByteArray != null) {
stmt.bindBlob(10, simpleByteArray);
}
}
示例7: bindValues
import android.database.sqlite.SQLiteStatement; //導入方法依賴的package包/類
@Override
protected final void bindValues(SQLiteStatement stmt, SimpleEntity entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
Boolean simpleBoolean = entity.getSimpleBoolean();
if (simpleBoolean != null) {
stmt.bindLong(2, simpleBoolean ? 1L: 0L);
}
Byte simpleByte = entity.getSimpleByte();
if (simpleByte != null) {
stmt.bindLong(3, simpleByte);
}
Short simpleShort = entity.getSimpleShort();
if (simpleShort != null) {
stmt.bindLong(4, simpleShort);
}
Integer simpleInt = entity.getSimpleInt();
if (simpleInt != null) {
stmt.bindLong(5, simpleInt);
}
Long simpleLong = entity.getSimpleLong();
if (simpleLong != null) {
stmt.bindLong(6, simpleLong);
}
Float simpleFloat = entity.getSimpleFloat();
if (simpleFloat != null) {
stmt.bindDouble(7, simpleFloat);
}
Double simpleDouble = entity.getSimpleDouble();
if (simpleDouble != null) {
stmt.bindDouble(8, simpleDouble);
}
String simpleString = entity.getSimpleString();
if (simpleString != null) {
stmt.bindString(9, simpleString);
}
byte[] simpleByteArray = entity.getSimpleByteArray();
if (simpleByteArray != null) {
stmt.bindBlob(10, simpleByteArray);
}
}