@MediumTest public void testBlob() throws Exception { // create table mDatabase.execSQL( "CREATE TABLE test (_id INTEGER PRIMARY KEY, s TEXT, d REAL, l INTEGER, b BLOB);"); // insert blob Object[] args = new Object[4]; byte[] blob = new byte[1000]; byte value = 99; Arrays.fill(blob, value); args[3] = blob; String s = new String("text"); args[0] = s; Double d = 99.9; args[1] = d; Long l = (long) 1000; args[2] = l; String sql = "INSERT INTO test (s, d, l, b) VALUES (?,?,?,?)"; mDatabase.execSQL(sql, args); // use cursor to access blob Cursor c = mDatabase.query("test", null, null, null, null, null, null); c.moveToNext(); ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(c, cv); int bCol = c.getColumnIndexOrThrow("b"); int sCol = c.getColumnIndexOrThrow("s"); int dCol = c.getColumnIndexOrThrow("d"); int lCol = c.getColumnIndexOrThrow("l"); byte[] cBlob = c.getBlob(bCol); assertTrue(Arrays.equals(blob, cBlob)); assertEquals(s, c.getString(sCol)); assertEquals((double) d, c.getDouble(dCol)); assertEquals((long) l, c.getLong(lCol)); // new byte[] byte[] newblob = new byte[1000]; value = 98; Arrays.fill(blob, value); c.updateBlob(bCol, newblob); cBlob = c.getBlob(bCol); assertTrue(Arrays.equals(newblob, cBlob)); // commit assertTrue(c.commitUpdates()); assertTrue(c.requery()); c.moveToNext(); cBlob = c.getBlob(bCol); assertTrue(Arrays.equals(newblob, cBlob)); c.close(); }