title: Why am I getting access denied on Firebase Database
body: <p>I am getting Permission Denied whenever I try to read from my database (I can write)</p>
  
  <pre><code>  /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
    "rules": {
      "Users": {
        "$user_id":{
          ".read": "$user_id == auth.uid",
          ".write": "$user_id == auth.uid"
        }
      }
    }
  }
  </code></pre>
  
  <p>This is an activity that is supposed to retrieve every user in the database (I have 20)</p>
  
  <pre><code>
  import android.content.Context;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.EditText;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  import androidx.fragment.app.Fragment;
  import androidx.recyclerview.widget.LinearLayoutManager;
  import androidx.recyclerview.widget.RecyclerView;
  
  import com.example.shrinkio.Adapter.UserAdapter;
  import com.example.shrinkio.R;
  import com.example.shrinkio.model.User;
  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.Query;
  import com.google.firebase.database.ValueEventListener;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class PeopleFragment extends Fragment {
  
      private RecyclerView recyclerView;
      private UserAdapter userAdapter;
      private List&lt;User&gt; mUsers;
  
      EditText search_bar;
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_people, container, false);
  
          recyclerView = view.findViewById(R.id.recycler_view);
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
  
          search_bar = view.findViewById(R.id.search_bar);
          mUsers = new ArrayList&lt;&gt;();
          userAdapter = new UserAdapter(getContext(), mUsers);
          recyclerView.setAdapter(userAdapter);
  
          readUsers();
          search_bar.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
               searchUsers(charSequence.toString().toLowerCase());
              }
  
              @Override
              public void afterTextChanged(Editable editable) {
  
              }
          });
  
          return view;
      }
  
      private void searchUsers(String s) {
          Query query = FirebaseDatabase.getInstance().getReference("Users").child("user_Id").orderByChild("Name").startAt(s).endAt(s+"\uf8ff");
  
          query.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  mUsers.clear();
                  for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                      User user = snapshot.getValue(User.class);
                      mUsers.add(user);
                  }
                  userAdapter.notifyDataSetChanged();
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
  
              }
          });
      }
  
      public void readUsers(){
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Users");
          reference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  if ( search_bar.getText().toString().equals("")) {
                      mUsers.clear();
                      for (DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()){
                          User user = dataSnapshot.getValue(User.class);
                          mUsers.add(user);
                      }
  
                  }            }
  
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
  
              }
          });
      }
  }
  </code></pre>
  
  <p>As previously mentioned, I am supposed to get 20 users, on a recycler view, however, no error occurs, but, the activity remains blank and once I check logcat I get the following error.</p>
  
  <p>It does show as an error, but I can't see the posts that are on the db or any user info:</p>
  
  <p><code>W/SyncTree: Listen at /Users failed: DatabaseError: Permission denied</code></p>