title: How to only store data for current logged in user using Firestore
body: <p>Below is the code which allows the user to store data into Firestore. The problem is, the uploaded data is viewable for all the users logged into the app. 
  How would I be able to only allow the current user logged in to store the data for their account only?</p>
  
  <p>With Firebase Database I use the following code (which works, but not for Firestore)   </p>
  
  <p>FirebaseUser user= FirebaseAuth.getInstance().getCurrentUser();
    String userId=user.getUid(); 
   mDatabaseRef =    FirebaseDatabase.getInstance().getReference(FB_DATABASE_PATH).child(userId);</p>
  
  <p>The above lines of code allows the data to be stored and retrieved only for the logged in user. So the data is unique to them only. </p>
  
  <p>How can I replicate that for Firestore?</p>
  
  <pre><code> fetch=findViewById(R.id.fetchDocument);
  
      firestore = FirebaseFirestore.getInstance();
  
      upload =findViewById(R.id.uploadText);
  
      upload.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              POJO pojo = new POJO();
              pojo.setValue("Hello World");
  
              //below code creates collection, creates a inner doc. and uploads the value (pojo)
  
              firestore.collection("RootCollection").document("MyDoc")
                      .set(pojo).addOnSuccessListener(new OnSuccessListener&lt;Void&gt;() {
                  @Override
                  public void onSuccess(Void aVoid) {
  
  
                      //gets called if upload is successful
                      Toast.makeText(ichild.this,"Upload is successful", Toast.LENGTH_SHORT).show();
  
                  }
              }).addOnFailureListener(new OnFailureListener() {
                  @Override
                  public void onFailure(@NonNull Exception e) {
                      Toast.makeText(ichild.this,"Upload is not successful" + e.getMessage(), Toast.LENGTH_SHORT).show();
                  }
              });
  
          }
      });
  
      fetch.setOnClickListener(new View.OnClickListener() {
  </code></pre>