开发者

Exception when getting photo content of contacts..

开发者 https://www.devze.com 2023-01-13 10:34 出处:网络
I am using below code toget the photo from my contacts.. but this is throwing exception.. android.database.sqlite.SQLiteException: unknown error: INTEGER data in getBlob_native.

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 = cu开发者_开发百科rsor.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); 


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.


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

Android - How do I load a contact Photo?

0

精彩评论

暂无评论...
验证码 换一张
取 消