I am a nooby android developer and am trying to convert bitmap image into byte array and store that value in Mysql database.
The following code is working great and the value is stored in the database, but am not sure if this is the real image or not..
Here's the code am using to convert the image:
Bitmap bitmap = BitmapFactory.decodeFile(file_path);
ByteArrayOutputStream blob = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG,100, blob);
bitmapdata = blob.toByteArray();
//System.out.println(blob.toByteArray());
bitmap.recycle();
bitmap = null;
photo_string = bitmapdata.toString();
System.out.print(photo_string);
try {
blob.close();
blob = null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and here's the HttpPost part:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("InsertIntoDB.php");
pairs.add(new BasicNameValuePair("img",photo_string ));
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = client.execute(post);
The value stored in DB is something like: [B@4285096
is the really the image itself ?? Please help with that.