title: Store Url in Firebase
body: <p>I am relatively new to android development and I was attempting to save an image url from firebase storage to firebase realtime database. </p>
  
  <p>However, when I save the link to the realtime database it is saved as a link like <code>"com.google.android.gms.tasks.zzu@c834bfd"</code></p>
  
  <p>rather than a normal http link, it is saved like above and I am not sure exactly what I need to change. </p>
  
  <pre><code>    package com.example.android.gymbuddies;
  
  import android.app.DatePickerDialog;
  import android.content.Intent;
  import android.graphics.Color;
  import android.graphics.drawable.ColorDrawable;
  import android.net.Uri;
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.v7.app.AppCompatActivity;
  import android.text.TextUtils;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.DatePicker;
  import android.widget.EditText;
  import android.widget.ProgressBar;
  import android.widget.RadioButton;
  import android.widget.RadioGroup;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.google.android.gms.tasks.OnCompleteListener;
  import com.google.android.gms.tasks.Task;
  import com.google.firebase.auth.FirebaseAuth;
  import com.google.firebase.database.DataSnapshot;
  import com.google.firebase.database.DatabaseError;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  import com.google.firebase.database.ValueEventListener;
  import com.google.firebase.storage.FirebaseStorage;
  import com.google.firebase.storage.StorageReference;
  import com.google.firebase.storage.UploadTask;
  import com.squareup.picasso.Picasso;
  import com.theartofdev.edmodo.cropper.CropImage;
  import com.theartofdev.edmodo.cropper.CropImageView;
  
  import java.util.Calendar;
  import java.util.HashMap;
  
  import de.hdodenhof.circleimageview.CircleImageView;
  
  public class setUpDetailsActivity extends AppCompatActivity {
  
      EditText username, fullName, height, weight;
      TextView dob;
      DatePickerDialog.OnDateSetListener mDateSetListener;
      CircleImageView profileIV;
      Button saveBT;
      ProgressBar progressbar;
      RadioGroup gender;
      RadioButton genderOption;
  
      private FirebaseAuth mAuth;
      private DatabaseReference userRef;
      private StorageReference profileImageRef;
  
      String currentUserID, strGender;
      final static int galleryPic = 1;
      private String TAG;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_set_up_details);
  
          mAuth = FirebaseAuth.getInstance();
          currentUserID = mAuth.getCurrentUser().getUid();
          userRef = FirebaseDatabase.getInstance().getReference().child("Users").child(currentUserID);
          profileImageRef = FirebaseStorage.getInstance().getReference().child("Profile Images");
  
          username = (EditText) findViewById(R.id.username);
          fullName = (EditText) findViewById(R.id.fullName);
          height = (EditText) findViewById(R.id.height);
          weight = (EditText) findViewById(R.id.weight);
          gender = findViewById(R.id.gender);
          dob = (TextView) findViewById(R.id.dob);
          saveBT = (Button) findViewById(R.id.saveBT);
          profileIV = (CircleImageView) findViewById(R.id.profileIV);
          progressbar = (ProgressBar) findViewById(R.id.progressbar);
  
  
          saveBT.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  saveAccountDetails();
              }
          });
  
          profileIV.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent galleryIntent = new Intent();
                  galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
                  galleryIntent.setType("image/*");
                  startActivityForResult(galleryIntent, galleryPic);
              }
          });
  
          dob.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Calendar cal = Calendar.getInstance();
                  int year = cal.get(Calendar.YEAR);
                  int month = cal.get(Calendar.MONTH);
                  int day = cal.get(Calendar.DAY_OF_MONTH);
  
                  DatePickerDialog dialog = new DatePickerDialog(
                          setUpDetailsActivity.this,
                          android.R.style.Theme_Holo_Light_Dialog_MinWidth,
                          mDateSetListener,
                          year,month,day);
                  dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                  dialog.show();
              }
          });
  
  
  
          mDateSetListener = new DatePickerDialog.OnDateSetListener() {
              @Override
              public void onDateSet(DatePicker datePicker, int year, int month, int day) {
                  month = month + 1;
                  Log.d(TAG, "onDateSet: dd/mm/yyy: " + day + "/" + month + "/" + year);
  
                  String date = day + "/" + month + "/" + year;
                  dob.setText(date);
              }
          };
          userRef.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  if(dataSnapshot.exists()){
                      if (dataSnapshot.hasChild("profileImage")){
                          String image1 = dataSnapshot.child("profileImage").getValue(String.class);
                          Picasso.get().load(image1).placeholder(R.drawable.ic_profilepic).into(profileIV);
                      }
                      else{
                          Toast.makeText(setUpDetailsActivity.this, "Please enter you image first", Toast.LENGTH_LONG).show();
                      }
  
                  }
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
  
              }
          });
      }
  
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          if (requestCode==galleryPic &amp;&amp; resultCode==RESULT_OK &amp;&amp; data!= null) {
              Uri ImageUri = data.getData();
  
              CropImage.activity()
                      .setGuidelines(CropImageView.Guidelines.ON)
                      .setAspectRatio(1, 1)
                      .start(this);
  
          }
  
              if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
  
                  progressbar.setVisibility(View.VISIBLE);
                  CropImage.ActivityResult result = CropImage.getActivityResult(data);
  
                  if (resultCode == RESULT_OK) {
  
                      Uri resultUri = result.getUri();
  
                      StorageReference filePath = profileImageRef.child(currentUserID + ".jpg");
  
                      filePath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener&lt;UploadTask.TaskSnapshot&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) {
                              if (task.isSuccessful()) {
                                  Toast.makeText(setUpDetailsActivity.this, "Profile image stored in firebase storage successfully", Toast.LENGTH_LONG).show();
  
                                  final String downloadUrl = task.getResult().getMetadata().getReference().getDownloadUrl().toString().trim();
                                  userRef.child("profileImage").setValue(downloadUrl).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
  
                                      @Override
                                      public void onComplete(@NonNull Task&lt;Void&gt; task) {
                                          progressbar.setVisibility(View.GONE);
                                          if (task.isSuccessful()) {
                                              Intent selfIntent = new Intent(setUpDetailsActivity.this, setUpDetailsActivity.class);
                                              startActivity(selfIntent);
                                              Toast.makeText(setUpDetailsActivity.this, "Profile image stored in firebase database successfully", Toast.LENGTH_LONG).show();
  
  
                                          } else {
                                              String message = task.getException().getMessage();
                                              Toast.makeText(setUpDetailsActivity.this, "Error Occured: " + message, Toast.LENGTH_LONG).show();
  
                                          }
                                      }
                                  });
  
                              } else {
                                  Toast.makeText(setUpDetailsActivity.this, "Error Occured: not stored in firebase storage", Toast.LENGTH_LONG).show();
  
                              }
                          }
                      });
  
                  } else {
  
                      Toast.makeText(setUpDetailsActivity.this, "Error Occured: Image can not be cropped try again.", Toast.LENGTH_LONG).show();
                      progressbar.setVisibility(View.GONE);
  
                  }
              }
  
      }
  
      private void saveAccountDetails() {
          String musername = username.getText().toString();
          String mfullname = fullName.getText().toString();
          String mheight = height.getText().toString();
          String mweight = weight.getText().toString();
          String mdob = dob.getText().toString();
          gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(RadioGroup group, int checkedId) {
                  genderOption = gender.findViewById(checkedId);
  
                  switch (checkedId){
                      case R.id.male:
                          strGender = genderOption.getText().toString();
                          break;
                      case R.id.female:
                          strGender = genderOption.getText().toString();
                          break;
  
                      default:
  
                  }
              }
          });
  
  
  
          if (TextUtils.isEmpty(musername)) {
              Toast.makeText(this, "Please Enter your Username", Toast.LENGTH_LONG).show();
          }
          if (TextUtils.isEmpty(mfullname)) {
              Toast.makeText(this, "Please Enter your Full Name", Toast.LENGTH_LONG).show();
          }
          if (TextUtils.isEmpty(mheight)) {
              Toast.makeText(this, "Please Enter your Height in cm", Toast.LENGTH_LONG).show();
          }
          if (TextUtils.isEmpty(mweight)) {
              Toast.makeText(this, "Please Enter your Weight in lbs", Toast.LENGTH_LONG).show();
          }
          if (TextUtils.isEmpty(mdob)) {
              Toast.makeText(this, "Please Enter your Date-Of-Birth", Toast.LENGTH_LONG).show();
          }
          if (TextUtils.isEmpty(strGender)) {
              Toast.makeText(this, "Please Select your Gender", Toast.LENGTH_LONG).show();
          }else {
              progressbar.setVisibility(View.VISIBLE);
              HashMap userMap = new HashMap();
              userMap.put("username", musername);
              userMap.put("fullName", mfullname);
              userMap.put("liftingGoal", "Default");
              userMap.put("height", mheight + " cm");
              userMap.put("weight", mweight + " pounds");
              userMap.put("dob", mdob);
              userMap.put("gender", strGender);
  
              userRef.updateChildren(userMap).addOnCompleteListener(new OnCompleteListener() {
                  @Override
                  public void onComplete(@NonNull Task task) {
                      progressbar.setVisibility(View.GONE);
                      if (task.isSuccessful()) {
                          sendUserToMainActivity();
                          Toast.makeText(setUpDetailsActivity.this, "Account created Successfully", Toast.LENGTH_LONG).show();
                      } else {
                          String message = task.getException().getMessage();
                          Toast.makeText(setUpDetailsActivity.this, "An Error Occured: " + message, Toast.LENGTH_LONG).show();
                      }
                  }
              });
          }
      }
  
  
      private void sendUserToMainActivity() {
          Intent mainIntent = new Intent(setUpDetailsActivity.this, MainActivity.class);
          mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
          startActivity(mainIntent);
          finish();
      }
  }
  </code></pre>