I'm trying to store and array of bytes (byte[]) into a DB. I have the array of bytes, a content provider and a database. When I try to insert into the Blob the insert returns -1. Can somebody show me how to get this done.
Insert
byte[] inData = nw.receive();
ContentValues values = new ContentValues();
values.put(InDatabase.Columns.DATA, inData);
values.put(InDatabase.Columns.SIZE, inData.length);
NetService.this.getContentResolver().insert(InContentProvider.CONTENT_URI, values);
Content Provider
mDB = mDBHelper.getWritableDatabase();
Long rowId = mDB.insert(mDBHelper.tableName(), null, aValues);
Database
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE table " + TABLE_NAME + "(id INTEGER PRIMARY KEY AUTOINCREMENT, data BLOB, size INTEGER);");
}
Like I said If I don't put the values.put(InDatabase.Columns.DATA, inData), it works perfect.