I have an image stored in the database in this form
"/9j/4AAQSkZJRgABAQAAAQABAAD/2w <...> igD//2Q=="
so definitely base64 encoded.
I get it via a php function:
...
$query = $db->prepare("SELECT `Data` FROM `UserPicture` WHERE `UserId` = ?");
$query->bind_param('i', $id);
$query->execute();
$query->bind_result($data);
$query->fetch();
echo base64_encode($data);
Android gets it via a call:
StringBuffer result = m_dbi.getResult(Constants.SERVER_HOST_PHP + "/get_user_picture.php", params, "GET");
Debugging I've seen that result is correct.
I pass result.toString() to a writeImageToFile(String pic) that does:
...
byte[] decodedByte = Base64.decode(pic, Base64.DEFAULT);
Bitmap bm = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
...
pic is correct as well as decodedByte.length but bm is always null.
I've tried to change Base64.DEFAULT to NO_PADDING or NO_WRAP but always null.
What could be the reason ?