In MySQL Database
i have a table containing name and image
. I want to get those details into android.
I used PHP
to get the data from Database
.
My PHP code
:
<?php
$db_host = $_POST['db_host'];
$db_uname = $_POST['db_user_name'];
$db_password = $_POST['db_password'];
$conn = mysql_connect($db_host, $db_uname, $db_password);
$query = $_POST['query'];
$db_name = $_POST['db_name'];
mysql_select_db($db_name);
$result_set = mysql_query($query, $conn);
while($row = mysql_fetch_array($result_set)) {
print "name:{$row['name']},image:" . base64_decode($row['image']) . ";
}
mysql_close($conn);
?>
I get name
perfectly as it is and image
in below format
LzlqLzRBQVFTa1pKUmdBQkFnRUFZQUJnQUFELzdnQU9RV1J2WW1VQVpBQUFBQUFCLytFVFhVVjRhV1lBQUUxTkFDb0FBQUFJQUFjQk1nQUNBQUFBRkFBQUFHSUJPd0FDQUFBQUJ3QUFBSFpIUmdBREFBQUFBUUFFQUFCSFNRQURBQUFBQVFBL0FBQ2NuUU
The format shown above is just as an example.
The string i get as image is saved to SQLite Database
using ContentValues
.
And now i need to display the image
saved in SQLite
on android screen.
My code is like :
ByteArrayInputStream input_stream = new ByteArrayInputStream(moviesList.get(i).getMovieImage());
Bitmap bitmap = BitmapFactory.decodeStream(input_stream);
movie_image.setImageBitmap(bitmap);
But i am not able to get the image ?
Please help me to solve this issue. Thank You