I'm new to Android development and I'm trying to insert an image into a database but its not working. Below is some of my code:
On click Code
public void click(View v){
img= DatabaseHandler.getBytes(BitmapFactory.decodeResource(getResources(), R.drawable.test));
DatabaseHandler.insertFood("test","test",10.00,img);
Toast toast = Toast.makeText(getApplicationContext(), "TEST", Toast.LENGTH_LONG);
toast.show();
}
DatabaseHandler Class
public static long insertFood( String Name, String Description, Double Price,Byte[] Image ){
ContentValues cv = new ContentValues();
cv.put(nam,Name);
cv.put(descrp, Description);
cv.put(prc, Price);
cv.put(img, Image);
return sdb.insert(TABLE, null, cv);
}
public static byte[] getBytes(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0, stream);
return stream.toByteArray();
}
The error

Image 2
