title: Unable to Store the image for the second time in to the firebase storage
body: <p>I created a simple application in which the user can browse through his/her gallery and after selecting the image option for cropping the image appears for that I have used some image crop library which was available on GitHub.
  All works fine I am able to crop the image and upload it after that image appears into the fire base storage, but when I try to upload the image for the second time with different image it doesn't get uploaded in the firebase storage and only the first uploaded image appears. Please help me anyone to do something with this code so that it could upload multiple images</p>
  
  <p><strong><em>XML Layout for MainActivity.java</em></strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="imgcrop.example.com.androidimagecrop.MainActivity"&gt;
  
      &lt;ImageButton
          android:id="@+id/imageview"
          android:layout_width="200dp"
          android:layout_height="200dp"
          android:layout_gravity="center"
          android:layout_marginTop="10dp"
          android:background="#FFFFFF"
          android:scaleType="centerCrop"
          android:src="@android:drawable/ic_menu_report_image"
          android:visibility="visible" /&gt;
  
      &lt;Button
          android:id="@+id/uploadbutton"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="UPLOAD IMAGE"
          android:layout_marginTop="10dp"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong><em>MainActivity.java</em></strong></p>
  
  <pre><code>package imgcrop.example.com.androidimagecrop;
  
  import android.content.Intent;
  import android.database.Cursor;
  import android.graphics.Bitmap;
  import android.net.Uri;
  import android.os.Bundle;
  import android.provider.MediaStore;
  import android.support.annotation.NonNull;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ImageButton;
  import android.widget.Toast;
  
  import com.firebase.client.Firebase;
  import com.google.android.gms.tasks.OnFailureListener;
  import com.google.android.gms.tasks.OnSuccessListener;
  import com.google.firebase.storage.FirebaseStorage;
  import com.google.firebase.storage.StorageReference;
  import com.google.firebase.storage.UploadTask;
  import com.theartofdev.edmodo.cropper.CropImage;
  import com.theartofdev.edmodo.cropper.CropImageView;
  
  import java.io.ByteArrayOutputStream;
  
  public class MainActivity extends AppCompatActivity {
  
      private ImageButton imageButton;
      private Button uploadButton;
      private  static  final  int Image_request=1;
      FirebaseStorage storage = FirebaseStorage.getInstance();
      StorageReference storageRef = storage.getReferenceFromUrl("gs://androidimagecrop.appspot.com");
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Firebase.setAndroidContext(this);
          //getting the reference of the views
          imageButton = (ImageButton) findViewById(R.id.imageview);
          uploadButton = (Button) findViewById(R.id.uploadbutton);
          onImageViewClick(); // for selecting an Image from gallery.
          onUploadButtonClick(); // for uploading the image to Firebase Storage.
      }
  
      protected  void onImageViewClick(){
          imageButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent();
                  intent.setType("image/*");
                  intent  .setAction(Intent.ACTION_GET_CONTENT);
                  startActivityForResult(intent,Image_request );
              }
          });
  
      }
      protected  void onActivityResult(int requestCode, int resultCode, Intent data){
          super.onActivityResult(requestCode, resultCode, data);
          if(requestCode == Image_request &amp;&amp; resultCode == RESULT_OK){
                  Uri selectedImageUri = data.getData();
              CropImage.activity(selectedImageUri)
                      .setGuidelines(CropImageView.Guidelines.ON)
                      .setAspectRatio(1, 1)
                      .start(this);
                  if (null != selectedImageUri) {
                      // Get the path from the Uri
                      String path = getPathFromURI(selectedImageUri);
                      imageButton.setImageURI(selectedImageUri);
  
                  }
  
          }
          if (requestCode==CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE)
          {
              CropImage.ActivityResult result= CropImage.getActivityResult(data);
              if(resultCode==RESULT_OK)
              {
                 Uri resulturi=result.getUri();
                  imageButton.setImageURI(resulturi);
                  StorageReference filepath=  storageRef.child(resulturi.getLastPathSegment());
              }
              else
              {
                  if(resultCode==CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE)
                  {
                      Exception error=result.getError();
                  }
              }
          }
      }
      private String getPathFromURI(Uri contentUri) {
          String res = null;
          String[] proj = {MediaStore.Images.Media.DATA};
          Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
          if (cursor.moveToFirst()) {
              int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
              res = cursor.getString(column_index);
          }
          cursor.close();
          return res;
      }
  
      protected void onUploadButtonClick(){
  
          uploadButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                   storageRef = FirebaseStorage.getInstance().getReference().child("Profiles/image");
  
                  imageButton.setDrawingCacheEnabled(true);
                  imageButton.buildDrawingCache();
                  Bitmap bitmap = imageButton.getDrawingCache();
                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                  byte[] data = baos.toByteArray();
  
                  UploadTask uploadTask = storageRef.putBytes(data);
                  uploadTask.addOnFailureListener(new OnFailureListener() {
                      @Override
                      public void onFailure(@NonNull Exception exception) {
                          Toast.makeText(MainActivity.this, "TASK FAILED", Toast.LENGTH_SHORT).show();
                      }
                  }).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
  
                      @Override
                      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                          Toast.makeText(MainActivity.this, "Image Uploaded SucessFully", Toast.LENGTH_SHORT).show();
                          Uri downloadUrl =taskSnapshot.getDownloadUrl();
                          String DOWNLOAD_URL = downloadUrl.getPath();
  
                      }
                  });
              }
          });
  
      }
  }
  </code></pre>
  
  <p>But on changing the name of child reference which is in onUploadButtonClick() method, I am able to store different image 
  <a href="https://i.stack.imgur.com/uSxyy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uSxyy.png" alt="enter image description here"></a></p>
  
  <p>Here is my firebase storage section. I have created a root folder under which all images should get stored
  <a href="https://i.stack.imgur.com/0JXn1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0JXn1.png" alt="root folder"></a></p>
  
  <p><a href="https://i.stack.imgur.com/7kYzJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7kYzJ.png" alt="images"></a></p>