title: Social Network app: Profile photos don't appear correctly
body: <p>I created a social network app using Java language with the ability to insert a picture as a profile photo. If I try to upload a photo of mine it works but if other users try to do it using another device they don't see my photo and I don't see theirs. Basically everyone sees their own photo using their own device.</p>
  <p>However, despite uploading my profile photo properly, it tends to disappear after a period of time.</p>
  <p>How to fix it?</p>
  <p>Screenshot:</p>
  <p><a href="https://i.stack.imgur.com/SXo99.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/SXo99.jpg</a></p>
  <p>Code for try to setting profile photo:</p>
  <pre><code>firebaseFirestore.collection(&quot;Users&quot;).document(user_id).get().addOnCompleteListener(new OnCompleteListener&lt;DocumentSnapshot&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;DocumentSnapshot&gt; task) {
  
              if(task.isSuccessful()){
  
                  if(task.getResult().exists()){
  
                      String name = task.getResult().getString(&quot;name&quot;);
                      String image = task.getResult().getString(&quot;image&quot;);
                      String about = task.getResult().getString(&quot;about&quot;);
                      String skills = task.getResult().getString(&quot;skills&quot;);
  
                      mainImageUri = Uri.parse(image);
  
                      setupName.setText(name);
                      setupAbout.setText(skills);
                      setupSkills.setText(about);
  
                      RequestOptions placeholderRequest = new RequestOptions();
                      placeholderRequest = placeholderRequest.placeholder(R.drawable.defaultuser);
  
                      Glide.with(getApplicationContext())
                              .setDefaultRequestOptions(placeholderRequest)
                              .load(image)
                              .into(setupImage);
  
                  }
  
              } else {
  
                  String error = task.getException().getMessage();
  
                  Toast.makeText(SetupActivity.this, &quot;C'è stato un problema, riprova per favore.&quot;, Toast.LENGTH_LONG).show();
  
              }
  
              progressBar.setVisibility(View.INVISIBLE);
              setupButton.setEnabled(true);
          }
      });
  
      setupButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              final String user_name = setupName.getText().toString();
              final String about = setupAbout.getText().toString();
              final String userSkills = setupSkills.getText().toString();
  
  
              if (!TextUtils.isEmpty(user_name) &amp;&amp; mainImageUri != null) {
              progressBar.setVisibility(View.VISIBLE);
  
              if (isChanged) {
  
                      user_id = firebaseAuth.getCurrentUser().getUid();
                      final StorageReference image_path = storageReference.child(&quot;profile_images&quot;).child(user_id + &quot;.jpg&quot;);
                      image_path.putFile(mainImageUri).addOnCompleteListener(new OnCompleteListener&lt;UploadTask.TaskSnapshot&gt;() {
                          @Override
                          public void onComplete(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) {
  
                              if (task.isSuccessful()) {
  
                                  storeFirestore(task, user_name, about, userSkills, image_path);
                              } else {
  
                                  Toast.makeText(SetupActivity.this, &quot;C'è stato un problema, riprova per favore.&quot;, Toast.LENGTH_LONG).show();
                                  progressBar.setVisibility(View.INVISIBLE);
                              }
  
  
                          }
                      });
  
                  } else {
  
  
                  storeFirestore(null, user_name, about, userSkills, null);
              }
  
              } else {
  
               if(TextUtils.isEmpty(user_name))
                  {
                      Toast.makeText(SetupActivity.this, &quot;Per favore, inserisci un nickname!&quot;, Toast.LENGTH_LONG).show();
                  } else
                  {
                      Toast.makeText(SetupActivity.this, &quot;Per favore, inserisci una foto profilo!&quot;, Toast.LENGTH_LONG).show();
                  }
  
              }
          }
      });
  
      setupImage.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
  
                  if (ContextCompat.checkSelfPermission(SetupActivity.this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_DENIED) {
                      Snackbar snackbar = Snackbar.make(view, &quot;Hai autorizzato l'app ad accedere al tuo archivio esterno?&quot;, Snackbar.LENGTH_SHORT);
                      snackbar.show();
                      ActivityCompat.requestPermissions(SetupActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
                  } else {
                     BringImagePicker();
                  }
              } else {
                  BringImagePicker();
              }
          }
      });
  
  }
  
  private void storeFirestore(Task&lt;UploadTask.TaskSnapshot&gt; task, String user_name,
                              String userSkills, String about, StorageReference image_path){
  
      Uri download_uri = null;
      if(task != null) {
  
           task.getResult().getStorage().getDownloadUrl();
  
      } else {
  
         download_uri = mainImageUri;
  
      }
      Map&lt;String, String&gt; userMap = new HashMap&lt;&gt;();
       userMap.put(&quot;skills&quot;, userSkills);
      userMap.put(&quot;name&quot;, user_name);
      userMap.put(&quot;about&quot;, about);
      userMap.put(&quot;image&quot;, download_uri.toString());
      userMap.put(&quot;user_id&quot;, user_id);
  
  
      firebaseFirestore.collection(&quot;Users&quot;).document(user_id).set(userMap).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;Void&gt; task) {
              if (task.isSuccessful()){
  
                  Toast.makeText(SetupActivity.this, &quot;Le impostazioni sono state aggiornate!&quot;, Toast.LENGTH_LONG).show();
                  Intent mainIntent = new Intent(SetupActivity.this, MainActivity.class);
                  startActivity(mainIntent);
                  finish();
              } else {
  
                  Toast.makeText(SetupActivity.this, &quot;C'è stato un problema, riprova per favore.&quot;, Toast.LENGTH_LONG).show();
  
              }
  
              progressBar.setVisibility(View.INVISIBLE);
          }
      });
  }
  </code></pre>
  <p>In the first line &quot;user_id&quot; is &quot;firebaseAuth.getCurrentUser().getUid();&quot;</p>
  <p>Code for onActivityResult:</p>
  <p><a href="https://i.stack.imgur.com/BTRJv.png" rel="nofollow noreferrer">https://i.stack.imgur.com/BTRJv.png</a></p>