2

I am getting get a response in php in json array which holds two value "name" and "image"(in blob). I would like to convert the blob to bitmap in my android application. Can someone help me to solve this?

As you can see below, this is my php code.

$sql = "SELECT * FROM bim WHERE category = '$category'";
    $r = mysqli_query($conn,$sql);

    $result = array();

    while($res = mysqli_fetch_array($r)){

        array_push($result,array(
        "signText"=>$res['signText'],
        "image"=>$res['image'] // i'm not sure if this right
    )
    );
    }
    echo json_encode(array("result"=>$result));
    mysqli_close($conn);
nyi
  • 3,123
  • 4
  • 22
  • 45
pienapeace
  • 21
  • 1

1 Answers1

0

Assuming the blob data in the database is a base64 encoded representation of the image data, in your java application you will need to base64 decode the image data from the response. Take a look at this stack post.

Your php code looks to be functional. Although you will want to use prepared statements in production to help prevent sql injection attacks.

whitwhoa
  • 2,389
  • 4
  • 30
  • 61