title: The picture in the imageView does not change when the picture changes in the firebase database and storage
body: <p>What should I do if everything changes when changing the photo in the database, but for some reason it is not displayed in the image view, I use the firebase database, that is, when I register and put a profile photo, everything is fine, it is displayed both in the database and in the imageview, but when I try to change it then it changes in the database and in the storage and in the realtime database the link changes, but in all imageviews the old picture remains, I don’t know why so I checked which link I load in the imageview and output to the console, I don’t understand why. Please help me I don't know what to do</p>
  <p>Realtime Database:</p>
  <pre><code>users:
       &quot;user-uid&quot; {
             &quot;username&quot; : &quot;some-username&quot;
             &quot;level&quot; : &quot;some-level&quot;
             &quot;type&quot; : &quot;some-type&quot;
             &quot;surnameName&quot; : &quot;some-surnameName&quot;
             &quot;email&quot; : &quot;some-email&quot;
             &quot;profileImage&quot;: &quot;image-url&quot;
             }
  </code></pre>
  <p>Storage:</p>
  <pre><code>   profileImage{
           &quot;user-uid&quot; - some-img
      }
  </code></pre>
  <p>My MainActivity:</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
      ImageView btnAdd, btnHome;
      CircleImageView btnProfile;
  
      FirebaseAuth mAuth;
      FirebaseUser mUser;
      DatabaseReference mRef;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          mAuth = FirebaseAuth.getInstance();
          mUser = mAuth.getCurrentUser();
          mRef = FirebaseDatabase.getInstance().getReference().child(&quot;users&quot;).child(mUser.getUid());
  
          btnAdd = findViewById(R.id.addRecieptBtn);
          btnHome = findViewById(R.id.homePageBtn);
          btnProfile = findViewById(R.id.profile_image);
          
          mRef.child(&quot;profileImage&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  Glide.with(MainActivity.this).load(snapshot.getValue().toString()).into(btnProfile);
                  System.out.println(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          btnProfile.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(MainActivity.this,ProfileActivity.class);
                  startActivity(intent);
              }
          });
      }
  }
  </code></pre>
  <p>My ProfiileActivity:</p>
  <pre><code>public class ProfileActivity extends AppCompatActivity {
      ImageView btnAdd, btnHome;
      TextView level, type, username;
      CircleImageView profile_image, profile_image2;
      ImageButton lg, btnEdit;
  
      FirebaseAuth mAuth;
      FirebaseUser mUser;
      DatabaseReference mRef;
      StorageReference sRef;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_profile);
  
          mAuth = FirebaseAuth.getInstance();
          mUser = mAuth.getCurrentUser();
          mRef = FirebaseDatabase.getInstance().getReference().child(&quot;users&quot;).child(mUser.getUid());
          sRef = FirebaseStorage.getInstance().getReference().child(&quot;profileImage&quot;);
  
          level = findViewById(R.id.level);
          type = findViewById(R.id.type);
          username = findViewById(R.id.username);
          profile_image = findViewById(R.id.profile_image);
          profile_image2 = findViewById(R.id.profile_image2);
          lg = findViewById(R.id.logout);
          btnEdit = findViewById(R.id.btnEdit);
  
          btnAdd = findViewById(R.id.addRecieptBtn);
          btnHome = findViewById(R.id.homePageBtn);
  
          mRef.child(&quot;profileImage&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  Glide.with(ProfileActivity.this).load(snapshot.getValue().toString()).into(profile_image);
                  Glide.with(ProfileActivity.this).load(snapshot.getValue().toString()).into(profile_image2);
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;username&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  username.setText(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;level&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  level.setText(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;type&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  type.setText(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
  
          lg.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  mAuth.signOut();
                  Intent intent = new Intent(ProfileActivity.this, LoginActivity.class);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                  startActivity(intent);
              }
          });
          btnHome.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(ProfileActivity.this,MainActivity.class);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                  startActivity(intent);
              }
          });
          btnEdit.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(ProfileActivity.this,EditProfileActivity.class);
                  startActivity(intent);
              }
          });
  
  
      }
  }
  </code></pre>
  <p>My EditProfileActivity:</p>
  <pre><code>public class EditProfileActivity extends AppCompatActivity {
  
      CircleImageView profile_image;
      AutoCompleteTextView inputCountry;
      EditText inputUsername, inputNameSurname;
      Spinner autocomplete_type, autocomplete_level;
      private int REQUEST_CODE = 101;
      ImageButton btnSave;
      static String[] autotype = new String[1];
      static String[] autolevel = new String[1];
      static String[] level;
      static String[] type;
      ProgressDialog mLoad;
  
  
      FirebaseAuth mAuth;
      FirebaseUser mUser;
      DatabaseReference mRef;
      DatabaseReference mRef2;
      StorageReference sRef;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_edit_profile);
  
          mAuth = FirebaseAuth.getInstance();
          mUser = mAuth.getCurrentUser();
          mRef = FirebaseDatabase.getInstance().getReference().child(&quot;users&quot;).child(mUser.getUid());
          sRef = FirebaseStorage.getInstance().getReference().child(&quot;profileImage&quot;);
          mLoad = new ProgressDialog(this);
          {// declare all variables here}
          mRef.child(&quot;profileImage&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  Uri uri = Uri.parse(snapshot.getValue().toString());
                  Glide.with(EditProfileActivity.this).load(uri).into(profile_image);
                  System.out.println(uri.toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;username&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  inputUsername.setText(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;level&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  int spinnerPosition = Arrays.asList(level).indexOf(snapshot.getValue().toString());
                  autocomplete_level.setSelection(spinnerPosition);
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;type&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  int spinnerPosition = Arrays.asList(type).indexOf(snapshot.getValue().toString());
                  autocomplete_type.setSelection(spinnerPosition);
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;country&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  inputCountry.setText(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
          mRef.child(&quot;surnameName&quot;).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
                  inputNameSurname.setText(snapshot.getValue().toString());
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
  
          profile_image.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                  intent.setType(&quot;image/&quot;);
                  startActivityForResult(intent, REQUEST_CODE);
              }
  
          });
  
          btnSave.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  SaveData();
              }
          });
      }
  
      private void SaveData() {
          String username = inputUsername.getText().toString();
          String country = inputCountry.getText().toString();
          String ns = inputNameSurname.getText().toString();
          String level = autolevel[0].toString();
          String type = autotype[0].toString();
  
          if (username.isEmpty()) {
              inputUsername.setError(&quot;Username is required!&quot;);
              inputUsername.requestFocus();
              return;
          } else if (username.length() &lt; 3) {
              inputUsername.setError(&quot;Min username length should be 3 characters &quot;);
              inputUsername.requestFocus();
              return;
          } else if (country.isEmpty()) {
              inputCountry.setError(&quot;Country is required!&quot;);
              inputCountry.requestFocus();
              return;
          } else if (ns.isEmpty()) {
              inputNameSurname.setError(&quot;Name and Surname is required!&quot;);
              inputNameSurname.requestFocus();
              return;
          } else {
              mLoad.setTitle(&quot;Setup Profile&quot;);
              mLoad.setCanceledOnTouchOutside(false);
              mLoad.show();
              if (imageUri == null) {
                  if (username == null) {
                      mRef.child(&quot;username&quot;).addValueEventListener(new ValueEventListener() {
                          @Override
                          public void onDataChange(@NonNull DataSnapshot snapshot) {
                              mRef.child(&quot;username&quot;).setValue(snapshot.getValue().toString());
                          }
  
                          @Override
                          public void onCancelled(@NonNull DatabaseError error) {
  
                          }
                      });
                  } else {
                      mRef.child(&quot;username&quot;).setValue(username);
                  }
                  if (ns == null) {
                      mRef.child(&quot;surnameName&quot;).addValueEventListener(new ValueEventListener() {
                          @Override
                          public void onDataChange(@NonNull DataSnapshot snapshot) {
                              mRef.child(&quot;surnameName&quot;).setValue(snapshot.getValue().toString());
                          }
  
                          @Override
                          public void onCancelled(@NonNull DatabaseError error) {
  
                          }
                      });
                  } else {
                      mRef.child(&quot;surnameName&quot;).setValue(ns);
                  }
                  if (country == null) {
                      mRef.child(&quot;country&quot;).addValueEventListener(new ValueEventListener() {
                          @Override
                          public void onDataChange(@NonNull DataSnapshot snapshot) {
                              mRef.child(&quot;country&quot;).setValue(snapshot.getValue().toString());
                          }
  
                          @Override
                          public void onCancelled(@NonNull DatabaseError error) {
  
                          }
                      });
                  } else {
                      mRef.child(&quot;country&quot;).setValue(country);
                  }
                  mRef.child(&quot;level&quot;).setValue(level);
                  mRef.child(&quot;type&quot;).setValue(type);
                  mLoad.dismiss();
                  Intent intent = new Intent(EditProfileActivity.this, ProfileActivity.class);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                  startActivity(intent);
              } else {
                  sRef.child(mUser.getUid()).putFile(imageUri).addOnCompleteListener(new OnCompleteListener&lt;UploadTask.TaskSnapshot&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) {
                          if (task.isSuccessful()) {
                              sRef.child(mUser.getUid()).getDownloadUrl().addOnSuccessListener(new OnSuccessListener&lt;Uri&gt;() {
                                  @Override
                                  public void onSuccess(Uri uri) {
                                      if (username == null) {
                                          mRef.child(&quot;username&quot;).addValueEventListener(new ValueEventListener() {
                                              @Override
                                              public void onDataChange(@NonNull DataSnapshot snapshot) {
                                                  mRef.child(&quot;username&quot;).setValue(snapshot.getValue().toString());
                                              }
  
                                              @Override
                                              public void onCancelled(@NonNull DatabaseError error) {
  
                                              }
                                          });
                                      } else {
                                          mRef.child(&quot;username&quot;).setValue(username);
                                      }
                                      if (ns == null) {
                                          mRef.child(&quot;surnameName&quot;).addValueEventListener(new ValueEventListener() {
                                              @Override
                                              public void onDataChange(@NonNull DataSnapshot snapshot) {
                                                  mRef.child(&quot;surnameName&quot;).setValue(snapshot.getValue().toString());
                                              }
  
                                              @Override
                                              public void onCancelled(@NonNull DatabaseError error) {
  
                                              }
                                          });
                                      } else {
                                          mRef.child(&quot;surnameName&quot;).setValue(ns);
                                      }
                                      if (country == null) {
                                          mRef.child(&quot;country&quot;).addValueEventListener(new ValueEventListener() {
                                              @Override
                                              public void onDataChange(@NonNull DataSnapshot snapshot) {
                                                  mRef.child(&quot;country&quot;).setValue(snapshot.getValue().toString());
                                              }
  
                                              @Override
                                              public void onCancelled(@NonNull DatabaseError error) {
  
                                              }
                                          });
                                      } else {
                                          mRef.child(&quot;country&quot;).setValue(country);
                                      }
                                      mRef.child(&quot;level&quot;).setValue(level);
                                      mRef.child(&quot;type&quot;).setValue(type);
                                      mLoad.dismiss();
  
                                  }
                              });
                              mLoad.dismiss();
                              Intent intent = new Intent(EditProfileActivity.this, ProfileActivity.class);
                              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                              startActivity(intent);
                          } else {
                              mLoad.dismiss();
                              Toast.makeText(EditProfileActivity.this, &quot;Something went wrong please try again later&quot;, Toast.LENGTH_SHORT).show();
                          }
                      }
                  });
              }
          }
      }
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == REQUEST_CODE &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null) {
              imageUri = data.getData();
              profile_image.setImageURI(imageUri);
          }
      }
  }
  
  </code></pre>
  <p>My template EditProfile:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.EditProfileActivity&quot;&gt;
  
      &lt;include
          android:id=&quot;@+id/app_bar&quot;
          layout=&quot;@layout/main_appbar&quot; /&gt;
  
      &lt;androidx.cardview.widget.CardView
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;0dp&quot;
          android:layout_margin=&quot;40dp&quot;
          app:cardCornerRadius=&quot;20dp&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@+id/app_bar&quot;&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;&gt;
  
              &lt;de.hdodenhof.circleimageview.CircleImageView
                  android:id=&quot;@+id/profile_image&quot;
                  android:layout_width=&quot;140dp&quot;
                  android:layout_height=&quot;140dp&quot;
                  android:layout_marginTop=&quot;20dp&quot;
                  android:src=&quot;@drawable/profile&quot;
                  app:civ_border_color=&quot;#FF000000&quot;
                  app:civ_border_width=&quot;1dp&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
              &lt;EditText
                  android:id=&quot;@+id/inputUsername&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;24dp&quot;
                  android:ems=&quot;10&quot;
                  android:hint=&quot;Username&quot;
                  android:inputType=&quot;textPersonName&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/profile_image&quot; /&gt;
  
              &lt;EditText
                  android:id=&quot;@+id/inputNameSurname&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;16dp&quot;
                  android:ems=&quot;10&quot;
                  android:hint=&quot;Name Surname&quot;
                  android:inputType=&quot;textPersonName&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/inputUsername&quot; /&gt;
  
              &lt;AutoCompleteTextView
                  android:id=&quot;@+id/inputCountry&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;16dp&quot;
                  android:ems=&quot;10&quot;
                  android:hint=&quot;Country&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintHorizontal_bias=&quot;0.504&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/inputNameSurname&quot; /&gt;
  
              &lt;Spinner
                  android:id=&quot;@+id/autocomplete_level&quot;
                  android:layout_width=&quot;210dp&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:hint=&quot;Level&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/username&quot;&gt;&lt;/Spinner&gt;
  
              &lt;Spinner
                  android:id=&quot;@+id/autocomplete_type&quot;
                  android:layout_width=&quot;210dp&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:hint=&quot;Type of Food&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/type&quot;&gt;&lt;/Spinner&gt;
  
              &lt;ImageButton
                  android:id=&quot;@+id/btnSave&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;24dp&quot;
                  android:background=&quot;@android:color/transparent&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/autocomplete_type&quot;
                  app:srcCompat=&quot;@drawable/ic_button__3_&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/username&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;5dp&quot;
                  android:layout_marginEnd=&quot;217dp&quot;
                  android:fontFamily=&quot;@font/baloo&quot;
                  android:text=&quot;Select Your Level:&quot;
                  android:textSize=&quot;16sp&quot;
                  app:layout_constraintBottom_toTopOf=&quot;@+id/autocomplete_level&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintHorizontal_bias=&quot;0.0&quot;
                  app:layout_constraintStart_toStartOf=&quot;@+id/inputCountry&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/inputCountry&quot; /&gt;
  
              &lt;TextView
                  android:id=&quot;@+id/type&quot;
                  android:layout_width=&quot;0dp&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;5dp&quot;
                  android:layout_marginBottom=&quot;1dp&quot;
                  android:fontFamily=&quot;@font/baloo&quot;
                  android:gravity=&quot;center&quot;
                  android:text=&quot;Select Type Of Food(that you like):&quot;
                  android:textSize=&quot;16sp&quot;
                  app:layout_constraintBottom_toTopOf=&quot;@+id/autocomplete_type&quot;
                  app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                  app:layout_constraintHorizontal_bias=&quot;0.0&quot;
                  app:layout_constraintStart_toStartOf=&quot;parent&quot;
                  app:layout_constraintTop_toBottomOf=&quot;@+id/autocomplete_level&quot; /&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
      &lt;/androidx.cardview.widget.CardView&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>