Wednesday, 18 November 2015

Android set image in imageview from mysql blob


php code for getting blob type from databse


$product["description"] = $row["description"];
$product["before_tuning_graph"] = base64_encode($row['before_tuning_graph']);
$product["after_tuning_graph"] = base64_encode($row['after_tuning_graph']);





In java 

read the blob images as string 

//setting image for before tuning
try {
byte[] res1 = Base64.decode(arrayList.get(position).getBefore_tuning_graph(), 0);
    InputStream ins =new ByteArrayInputStream(res1);
    Drawable dUser = Drawable.createFromStream(ins , "immagine");
    imageViewBefore.setImageDrawable(dUser);
    
} catch (Exception e) {
e.printStackTrace();
}


No comments:

Post a Comment