I am using firebase as a backend for my android app and i want to save images on firebase and retrieve it back in my app.Somebody please tell me how to accomplish this.
Asked
Active
Viewed 4,588 times
0

Frank van Puffelen
- 565,676
- 79
- 828
- 807

Digvijay Singh Thakur
- 137
- 1
- 3
- 14
-
Have a look at this similar question: http://stackoverflow.com/a/13957446/1478764 – chRyNaN Apr 22 '16 at 19:37
-
Yup. Or one of these: https://www.google.com/search?q=site:stackoverflow.com+firebase+image+android – Frank van Puffelen Apr 22 '16 at 20:34
1 Answers
-1
You can store like this:
Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.chicken);//your image
ByteArrayOutputStream bYtE = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, bYtE);
bmp.recycle();
byte[] byteArray = bYtE.toByteArray();
String encodedImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
And then:
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
Good luck!

Federico Blumetto
- 967
- 1
- 7
- 12
-
How can i save images from phone gallery to firebase and what should i use in place of R.drawable.chicken . – Digvijay Singh Thakur May 07 '16 at 06:07
-
Terrible solution, when downloading too many images on base64 with high quality the app is prone to crash. – olegario Mar 23 '19 at 21:35