tags:

views:

14

answers:

1

Friend's, I stored image url has a byte array in database has blob type and at time of fetching this image i'm getting nullpointer exception.how can i fix this problem,here the code for fetching data from db... String bb = c.getString(c.getColumnIndex(JR_Constants.IMAGE_97)); Log.v(TAG,bb); Bitmap theImage = BitmapFactory.decodeByteArray(bb, 0, bb.length); myImage.setImageBitmap(theImage); what i'm doing mistake here.

A: 

You need to convert the String to a ByteArray. Basically just do bb.getBytes() instead of passing bb

String bb = c.getString(c.getColumnIndex(JR_Constants.IMAGE_97));
Log.v(TAG,bb);
Bitmap theImage = BitmapFactory.decodeByteArray(bb.getBytes(), 0, bb.length());
myImage.setImageBitmap(theImage);

I just want to note that bb.length should be bb.length()

kuroutadori
Actually you are wrong about length. bb.length is the correct spelling.
Sephy
bb is of type String not an array, so it's length() method.
kuroutadori