I'm working on android app in which i parse the data from the webservice and then store it in the database. here i also want to store the image in the database and retrive back in the next activity.
I'm using this code for inserting the image in database.
Bitmap yourSelectedImage;
ByteArrayOutputStream stream;
byte[] byteArray;
this is in the for loop
{
yourSelectedImage = BitmapFactory.decodeFile(SingleImageURL[i]);
stream = new ByteArrayOutputStream();
yourSelectedImage.compress(Bitmap.CompressFormat.PNG, 100,
stream);
byteArray = stream.toByteArray();
database.insertDetail(ID[i],byteArray[i]);
}
Here SingleImageURL have the image url that is coming from the webservice.
when i'm run the code it will give error nullPointerException in this line
yourSelectedImage.compress(Bitmap.CompressFormat.PNG, 100,
stream);
please tell me where i'm going wrong. and how to do this.