Code example for Cursor

Methods: closegetBlobgetCountmoveToFirst

0
                String[] selectionArgs = { String.valueOf(appWidgetId) };
                c = db.query(TABLE_PHOTOS, PHOTOS_PROJECTION, FIELD_APPWIDGET_ID + "=?",
                        selectionArgs, 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();
                } 
            } 
            return bitmap;
        }