I am working with images on edit profile page... in my android application. I am having trouble in converting image to base64 code... so help me to store and retrive images on my database... and I am using cake php & php myadmin.
Asked
Active
Viewed 50 times
0
-
1[How to convert a image into Base64 string?](http://stackoverflow.com/questions/4830711/how-to-convert-a-image-into-base64-string) – blizzard May 29 '14 at 07:41
1 Answers
0
Use This:
public String getBase64String(Bitmap photoBitmap) {
String photo;
if (photoBitmap != null) {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
photoBitmap.compress(Bitmap.CompressFormat.PNG, 100, bao);
// photoBitmap.recycle();
photo = android.util.Base64.encodeToString(bao.toByteArray(),
android.util.Base64.DEFAULT);
try {
bao.close();
bao = null;
photoBitmap = null;
} catch (Exception e) {
e.printStackTrace();
}
} else {
photo = "";
}
return photo;
}

Kishan Dhamat
- 3,746
- 2
- 26
- 36