Cursor getBlob - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Cursor getBlob method.

This code example shows how to use the following methods:getBlob, getDouble, getFloat, getInt, getLong
 
    /** @inheritdoc */ 
    @Override 
    public SimpleEntity readEntity(Cursor cursor, int offset) {
        SimpleEntity entity = new SimpleEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getShort(offset + 1) != 0, // simpleBoolean
            cursor.isNull(offset + 2) ? null : (byte) cursor.getShort(offset + 2), // simpleByte
            cursor.isNull(offset + 3) ? null : cursor.getShort(offset + 3), // simpleShort
            cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // simpleInt
            cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // simpleLong
            cursor.isNull(offset + 6) ? null : cursor.getFloat(offset + 6), // simpleFloat
            cursor.isNull(offset + 7) ? null : cursor.getDouble(offset + 7), // simpleDouble
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // simpleString
            cursor.isNull(offset + 9) ? null : cursor.getBlob(offset + 9) // simpleByteArray
        ); 
        return entity;
    } 
      
    /** @inheritdoc */ 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, getBlob, getInt, getString, moveToFirst
 
        Cursor cur = mDB.rawQuery("SELECT "
                + join(Consumers.PACKAGE_NAME, Consumers.IS_SERVICE_PUBLIC, 
                        Consumers.OWNS_CONSUMER_KEY, Consumers.REGISTRY_ID, Consumers.SIGNATURE) 
                + " FROM consumers", null); 
        assertTrue(cur.moveToFirst());
        assertEquals(PACKAGE_UNDER_TEST, cur.getString(0));
        assertEquals(0, cur.getInt(1));
        assertEquals(1, cur.getInt(2));
        assertEquals(1, cur.getInt(3));
        assertEquals(new Signature(SIGNATURE_FOR_PACKAGE), new Signature(cur.getBlob(4)));
        cur.close();
    } 
 
    public void testShouldUpdateCorrectly() throws Exception { 
        setPackage(PACKAGE_UNDER_TEST);
        setSignature(SIGNATURE_FOR_PACKAGE);
 
        ContentValues value = new ContentValues();
        value.put(Registry.ACCESS_TOKEN_URL, "http://access");
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, getBlob, getCount, moveToFirst
                                                 appWidgetId);
                c = db.query(TABLE_PHOTOS, PHOTOS_PROJECTION, selection, null,
                        null, null, null, null); 
 
                if (c != null && LOGD) {
                    Log.d(TAG, "getPhoto query count=" + c.getCount());
                } 
 
                if (c != null && c.moveToFirst()) {
                    byte[] data = c.getBlob(INDEX_PHOTO_BLOB);
                    if (data != null) {
                        bitmap = BitmapFactory.decodeByteArray(data, 0,
                                data.length);
                    } 
                } 
            } catch (SQLiteException e) {
                Log.e(TAG, "Could not load photo from database", e);
            } finally { 
                if (c != null) {
                    c.close();

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBlob, getColumnIndex
        return mDb.query(false, table, new String[] {KEY_BYTES}, null, null, null, null,
                KEY_PATH + " ASC", null);
    } 
 
    public static AbstractResult getAbstractResult(Cursor cursor) {
        return AbstractResult.create(cursor.getBlob(cursor.getColumnIndex(KEY_BYTES)));
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, getBlob, moveToFirst
        Cursor cursor = db.rawQuery(sql, selectionArgs);
        if (cursor == null) {
            return null; 
        } 
        try { 
            if (!cursor.moveToFirst()) {
                return null; 
            } 
            byte[] bytes = cursor.getBlob(0);
            if (bytes == null) {
                return null; 
            } 
            MemoryFile file = new MemoryFile(null, bytes.length);
            file.writeBytes(bytes, 0, 0, bytes.length);
             
         //   file.deactivate(); 
            return file;
        } finally { 
            cursor.close();
        } 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, getBlob, getColumnIndex, isAfterLast, moveToFirst
        Cursor cursor = builder.query(db, columns, selection, selectionArgs,
                groupBy, having, sortOrder);
 
        if (cursor == null) {
            return null; 
        } else if (!cursor.moveToFirst()) {
            cursor.close();
            return null; 
        } 
        return cursor;
    } 
 
    public SortedMap<Long, Sample> queryOldestSamples(int howmany) {
        SortedMap<Long, Sample> results = new TreeMap<Long, Sample>();
        try { 
            synchronized (dbLock) {
                if (db == null || !db.isOpen()) {
                	try{ 
                		db = helper.getWritableDatabase();
                	}catch (android.database.sqlite.SQLiteException ex){

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBlob, getInt, getLong, getString

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBlob, getString, moveToFirst
 
        database.insert("table_name", null, values);
 
        Cursor cursor = database.query("table_name", new String[]{"second_column", "first_column"}, null, null, null, null, null);
 
        assertThat(cursor.moveToFirst()).isTrue();
 
        byte[] byteValueFromDatabase = cursor.getBlob(0);
        String stringValueFromDatabase = cursor.getString(1);
 
        assertThat(stringValueFromDatabase).isEqualTo(stringColumnValue);
        assertThat(byteValueFromDatabase).isEqualTo(byteColumnValue);
    } 
 
    @Test 
    public void testInsertAndRawQuery() throws Exception { 
        String stringColumnValue = "column_value";
        byte[] byteColumnValue = new byte[]{1, 2, 3};
 
        ContentValues values = new ContentValues();
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getBlob, getColumnIndexOrThrow, getLong, moveToPosition
 
    public static final String TIME = "time";
    public static final String VALUE = "value";
 
    public static GenericObservation observationFromCursor(final Cursor c, int pos) {
		c.moveToPosition(pos);
		 
		final GenericObservation observation = new GenericObservation(
				c.getLong(c.getColumnIndexOrThrow(OBSERVATION_TYPE_ID)),
				c.getLong(c.getColumnIndexOrThrow(TIME)),
				c.getBlob(c.getColumnIndexOrThrow(VALUE)));
				 
		return observation;
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close, getBlob, moveToFirst
        final SQLiteDatabase db = openHelper.getReadableDatabase();
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        qb.setTables(DATABASE_TABLE);
        Cursor c = qb.query(db, new String[] {COL_IMAGE}, COL_ID + " = ?", new String[]{"" + id}, null, null, null);
        try { 
            if (!c.moveToFirst()) {
                return null; 
            } else { 
                return c.getBlob(0);
            } 
        } finally { 
            c.close();
        } 
    } 
 
    public Post getPost(long id) {
        final SQLiteDatabase db = openHelper.getReadableDatabase();
        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
        qb.setTables(DATABASE_TABLE);
        Cursor c = qb.query(db, null, COL_ID + " = ?", new String[]{"" + id}, null, null, null);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Cursor getBlob Questions & Answers:

getBlob Method Overview
Returns the value of the requested column as a byte array.
See Code Examples for other Android Cursor Methods: