title: How to append image name and download url to logged in users node in firebase
body: <p>I m trying to upload image to firebase storage and as per my need it is going to storage perfectly but in firebase database I m facing 2 isssues</p>
  
  <ol>
  <li>When I upload image the download Url is not the same which I see in storage. It appears to be something 
  like 
  <code>""com.google.android.gms.tasks.zzu@590df7c"
  </code></li>
  <li><p>The details of uploaded image is not appending to logged in users node. Instead it is uploading to database in separate node.</p>
  
  <pre><code>public class SecondActivity extends AppCompatActivity {
  private static final int CHOOSE_IMAGE = 101;
  String Database_Path = "users";
  String Storage_Path = "profilepics/";
  TextView textView;
  private ImageView imageView;
  EditText editText;
  Uri uriProfileImage;
  String downloadUri;
  ProgressBar progressBar;
   FirebaseAuth mAuth;
  String imageUrl;
  Button UploadButton;
  
  
  StorageReference storageReference;
  DatabaseReference databaseReference;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_second);
  
  mAuth = FirebaseAuth.getInstance();
  
  editText = (EditText) findViewById(R.id.editTextDisplayName);
  imageView = (ImageView) findViewById(R.id.imageView);
  UploadButton = (Button)findViewById(R.id.buttonSave);
  progressBar = (ProgressBar) findViewById(R.id.progressbar);
  
  
  storageReference = FirebaseStorage.getInstance().getReference();
  databaseReference = FirebaseDatabase.getInstance().getReference(Database_Path);
  
  progressBar = new ProgressBar(SecondActivity.this)
     imageView.setOnClickListener(new View.OnClickListener() {
           @Override
        public void onClick(View v) {
              showimagechooser();
      }
  });
  
  UploadButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
  
          // Calling method to upload selected image on Firebase storage.
  
          startActivity(new Intent(SecondActivity.this, DisplayProfile.class));
  
      }
  });
   }
  
  private void showimagechooser() {
  Intent intent = new Intent();
  intent.setType("image/*");
  intent.setAction(Intent.ACTION_GET_CONTENT);
  startActivityForResult(Intent.createChooser(intent, "Select profile Image"), CHOOSE_IMAGE);
  
   }
   @Override
   protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
  super.onActivityResult(requestCode, resultCode, data);
  
  if (requestCode == CHOOSE_IMAGE &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getData() != null) {
      uriProfileImage = data.getData();
      try {
          Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uriProfileImage);
          imageView.setImageBitmap(bitmap);
          uploadImageToFirebaseStorage(bitmap);
  
         } catch (IOException e) {
          e.printStackTrace();
         }
      }
   }
  
   private void uploadImageToFirebaseStorage(Bitmap bitmap) {
  final String TempImageName = editText.getText().toString().trim();
  
  FirebaseStorage storage = FirebaseStorage.getInstance();
  final StorageReference storageRef = storage.getReference();
  String userID=mAuth.getCurrentUser().getUid();
  System.out.println(userID);
  // this is how you set your desired name for the image
  final StorageReference ImagesRef = storageRef.child("images/"+mAuth.getCurrentUser().getUid()+".jpg");
  
  
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
  byte[] data = baos.toByteArray();
  final UploadTask uploadTask = ImagesRef.putBytes(data);
  
  uploadTask.addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception exception) {
          Log.i("whatTheFuck:",exception.toString());
      }
  }).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;(){
                              @RequiresApi(api = Build.VERSION_CODES.KITKAT)
                              @Override
                              public void onSuccess(final UploadTask.TaskSnapshot taskSnapshot) {
                                  Task&lt;Uri&gt; urlTask = uploadTask.continueWithTask(new Continuation&lt;UploadTask.TaskSnapshot, Task&lt;Uri&gt;&gt;() {
                                      @Override
                                      public Task&lt;Uri&gt; then(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) {
                                          if (!task.isSuccessful()) {
                                              Log.i("problem", task.getException().toString());
                                          }
  
                                          return ImagesRef.getDownloadUrl();
                                      }
                                  }).addOnCompleteListener(new OnCompleteListener&lt;Uri&gt;() {
                                      @Override
                                      public void onComplete(@NonNull Task&lt;Uri&gt; task) {
                                          if (task.isSuccessful()) {
                                              Uri downloadUri = task.getResult();
  
                                              DatabaseReference ref = FirebaseDatabase.getInstance().getReference("users").child(mAuth.getCurrentUser().getUid());
                                              ref.child("imageURL").setValue(downloadUri.toString());
                                              ref.child("imageName").setValue(TempImageName);
  
  
                                          } else {
                                              Log.i("wentWrong","downloadUri failure");
                                          }
                                      }
                                  });
                              }
  });
  
   }
   }
  </code></pre></li>
  </ol>
  
  <p>Here is link to My database
  <a href="https://i.stack.imgur.com/jZOUQ.png" rel="nofollow noreferrer">Database image</a></p>
  
  <p>Thanks in advance</p>