Can I store image files in firebase using Java API

Is there any way to store image files in firebase using Java api?


Try using this snippet:

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 imageFile = Base64.encodeToString(byteArray, Base64.DEFAULT); 

and for retrieving

public Bitmap stringToBitMap(String encodedString){
   try {
      byte [] encodeByte=Base64.decode(encodedString,Base64.DEFAULT);
      Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
      return bitmap;
   } catch(Exception e) {
      e.getMessage();
      return null;
   }
}