2

I am using below code to get the photo from my contacts.. but this is throwing exception..

android.database.sqlite.SQLiteException: unknown error: INTEGER data in getBlob_native.

please help me if I miss something.

int idx = cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID);

byte[] img = cursor.getBlob(idx);


ImageView i = (ImageView)findViewById(R.id.ImageView); 

Bitmap b = BitmapFactory.decodeByteArray(img, 0, img.length); 
Asha Soman
  • 1,821
  • 1
  • 15
  • 27
Brigadier
  • 21,663
  • 4
  • 15
  • 9

2 Answers2

6

The error is happing because you are trying to read the PHOTO_ID column as a blob. PHOTO_ID is a integer column that is the id of the row in the ContactsContract.Data provider that you can read to get the photo data.

Nic Strong
  • 6,363
  • 3
  • 32
  • 49
  • Thank you sooo much for this piece of information, this was driving me nuts... The documentation for PHOTO_ID says "Reference to the row in the data table holding the photo." I guess when they say "the data table" they mean the ContactsContract.Data table. – plainjimbo Sep 18 '11 at 05:10
1

In addition to Nic's answer this recent question may help you:

Android - How do I load a contact Photo?

Community
  • 1
  • 1
DonGru
  • 12,863
  • 8
  • 42
  • 55