title: How to update profile picture for firebase user android?
body: <p>I have a user that has a username, email, and profile pic, but I set profile pic as a null string on registration. I am trying to update the profile pic and set it with the current user, but I am getting an error.</p>
  
  <pre><code>mProfilePic.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(Intent.ACTION_PICK);
              intent.setType("image/*");
              intent.setAction(Intent.ACTION_GET_CONTENT);
              startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_INTENT);
          }
      });
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if(requestCode == GALLERY_INTENT &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getData() != null){
          mainImageURI = data.getData();
          try {
              Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mainImageURI);
              mProfilePic.setImageBitmap(bitmap);
              final ProgressDialog proDialog = new ProgressDialog(HomeActivity.this);
              proDialog.setTitle("Uploading...");
              proDialog.show();
  
              final StorageReference mRef = mStorage.child("Photos").child(mainImageURI.getLastPathSegment());
              mRef.putFile(mainImageURI).addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                      Task&lt;Uri&gt; uri = taskSnapshot.getMetadata().getReference().getDownloadUrl();
                      Log.i("uploaded", mDatabase.getReference("Users").child(mAuth.getCurrentUser().getUid()).child("image").setValue(uri).toString());
                      mDatabase.getReference("Users").child(mAuth.getCurrentUser().getUid()).child("image").setValue(uri).toString();
                      proDialog.dismiss();
                      Toast.makeText(HomeActivity.this, "Uploaded", Toast.LENGTH_LONG).show();
                  }
              })
              .addOnFailureListener(new OnFailureListener() {
                  @Override
                  public void onFailure(@NonNull Exception e) {
                      proDialog.dismiss();
                      Toast.makeText(HomeActivity.this, "Upload Failed "+e.getMessage(), Toast.LENGTH_LONG).show();
                  }
              })
              .addOnProgressListener(new OnProgressListener&lt;UploadTask.TaskSnapshot&gt;() {
                  @Override
                  public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                      double progress = (100.0*taskSnapshot.getBytesTransferred()/taskSnapshot.getTotalByteCount());
                      proDialog.setMessage("Uploaded "+(int)progress+"%");
                  }
              });
          } catch(IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>The code works if I take out anything that has to do with connecting to the user.</p>
  
  <p>Here is the error I get:</p>
  
  <pre><code>09-22 23:12:05.896 20706-20706/com.example.kisha.androidapp E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.kisha.androidapp, PID: 20706
      java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
          at com.google.android.gms.internal.firebase_database.zzku.zzm(Unknown Source:130)
          at com.google.android.gms.internal.firebase_database.zzkt.zzi(Unknown Source:253)
          at com.google.android.gms.internal.firebase_database.zzkt.zzh(Unknown Source:0)
          at com.google.firebase.database.DatabaseReference.zza(Unknown Source:10)
          at com.google.firebase.database.DatabaseReference.setValue(Unknown Source:7)
          at com.example.kisha.androidapp.HomeActivity$4.onSuccess(HomeActivity.java:129)
          at com.example.kisha.androidapp.HomeActivity$4.onSuccess(HomeActivity.java:125)
          at com.google.firebase.storage.zzi.zza(Unknown Source:13)
          at com.google.firebase.storage.zzac.zza(Unknown Source:2)
          at com.google.firebase.storage.zzaf.run(Unknown Source:6)
          at android.os.Handler.handleCallback(Handler.java:790)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6494)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
  </code></pre>
  
  <p>Users->(uid)->username, email, image
  Where all fields are strings and image is null when a user registers</p>