Example usage for android.database.sqlite SQLiteStatement bindBlob

List of usage examples for android.database.sqlite SQLiteStatement bindBlob

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteStatement bindBlob.

Prototype

public void bindBlob(int index, byte[] value) 

Source Link

Document

Bind a byte array value to this statement.

Usage

From source file:Main.java

public static void bindValores(SQLiteStatement statement, ContentValues contentValues) {
    Set<String> chaves = new TreeSet<>(contentValues.keySet());
    int index = 1;

    for (String chave : chaves) {
        Object valor = contentValues.get(chave);

        if (valor == null) {
            statement.bindNull(index);//from w  w w. j av  a  2s  . c  o  m

        } else if (valor instanceof String) {
            statement.bindString(index, (String) valor);

        } else if (valor instanceof Double || valor instanceof Float) {
            statement.bindDouble(index, Double.valueOf(String.valueOf(valor)));

        } else if (valor instanceof Integer || valor instanceof Long) {
            statement.bindLong(index, Long.valueOf(String.valueOf(valor)));
        } else if (valor instanceof byte[]) {
            statement.bindBlob(index, (byte[]) valor);
        }
        index++;
    }
}