title: Using an unspecified index
body: <p>Hello StackOverflow Community, I wrote a Code to Search Users in the Firebase Database and every time I try to launch the Code it doesn't Show me the users.</p>
  
  <p>In my Run log I get the following Message:</p>
  
  <p>W/PersistentConnection: pc_0 - Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "username"' at users to your security and Firebase Database rules for better Performance</p>
  
  <p>This is the Code which I wrote:</p>
  
  <pre><code>package com.example.ts.tsp.Fragment;
  
  
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.v4.app.Fragment;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  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 com.example.ts.tsp.Adapter.UserAdapter;
  import com.example.ts.tsp.Model1.User;
  import com.example.ts.tsp.R;
  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 SearchFragment extends Fragment {
  
      private RecyclerView recyclerView;
      private UserAdapter userAdapter;
      private List&lt;User&gt; mUsers;
  
      EditText search_bar;
  
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View view = inflater.inflate(R.layout.fragment_search, 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 s, int start, int count, int after) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  searchUsers(s.toString().toLowerCase());
  
              }
  
              @Override
              public void afterTextChanged(Editable s) {
  
              }
          });
          return view;
  
      }
  
      private void searchUsers(String s){
          Query query = FirebaseDatabase.getInstance().getReference("Users").orderByChild("username")
                  .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) {
  
              }
          });
      }
  
      private void readUsers(){
  
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference("User");
          reference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  if (search_bar.getText().toString().equals("")){
                      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) {
  
              }
          });
      }
  }
  </code></pre>
  
  <p>And the Other Class:</p>
  
  <pre><code>package com.example.ts.tsp.Adapter;
  
  
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.support.annotation.NonNull;
  import android.support.v4.app.FragmentActivity;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.TextView;
  
  import com.bumptech.glide.Glide;
  import com.example.ts.tsp.Fragment.ProfileFragment;
  import com.example.ts.tsp.Model1.User;
  import com.example.ts.tsp.R;
  import com.google.firebase.auth.FirebaseAuth;
  import com.google.firebase.auth.FirebaseUser;
  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.ValueEventListener;
  
  
  import java.util.List;
  
  import de.hdodenhof.circleimageview.CircleImageView;
  
  public class UserAdapter extends RecyclerView.Adapter&lt;UserAdapter.Viewholder&gt;{
  
  
      private Context mContext;
      private List&lt;User&gt; mUsers;
  
      private FirebaseUser firebaseUser;
  
      public UserAdapter(Context mContext, List&lt;User&gt; mUsers) {
          this.mContext = mContext;
          this.mUsers = mUsers;
      }
  
      @NonNull
      @Override
      public Viewholder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
          View view = LayoutInflater.from(mContext) .inflate(R.layout.user_item, viewGroup, false);
          return new UserAdapter.Viewholder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull final Viewholder viewHolder, int i) {
          firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
  
          final User user = mUsers.get(i);
  
          viewHolder.btn_follow.setVisibility(View.VISIBLE);
  
          viewHolder.username.setText(user.getUsername());
          viewHolder.fullname.setText(user.getFullname());
          Glide.with(mContext) .load(user.getImageurl()) .into(viewHolder.image_Profile);
          isFollowing(user.getId(), viewHolder.btn_follow);
  
          if (user.getId().equals(firebaseUser.getUid())){
  
              viewHolder.btn_follow.setVisibility(View.GONE);
  
          }
  
          viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  SharedPreferences.Editor editor = mContext.getSharedPreferences( "PREFS", Context.MODE_PRIVATE) .edit();
                  editor.putString("profileid", user.getId());
                  editor.apply();
  
                  ((FragmentActivity)mContext).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
                          new ProfileFragment()).commit();
              }
          });
  
          viewHolder.btn_follow.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (viewHolder.btn_follow.getText().toString().equals("follow")) {
                      FirebaseDatabase.getInstance().getReference().child("Follow").child(firebaseUser.getUid())
                              .child("following").child(user.getId()).setValue(true);
                      FirebaseDatabase.getInstance().getReference().child("Follow").child(user.getId())
                              .child("followers").child(firebaseUser.getUid()).setValue(true);
                  } else {
                      FirebaseDatabase.getInstance().getReference().child("Follow").child(firebaseUser.getUid())
                              .child("following").child(user.getId()).removeValue();
                      FirebaseDatabase.getInstance().getReference().child("Follow").child(user.getId())
                              .child("followers").child(firebaseUser.getUid()).removeValue();
  
                  }
              }
          });
  
      }
  
      @Override
      public int getItemCount() {
          return 0;
      }
  
      public class Viewholder extends RecyclerView.ViewHolder{
  
          public TextView username;
          public TextView fullname;
          public CircleImageView image_Profile;
          public Button btn_follow;
  
          public Viewholder(@NonNull View itemView) {
              super(itemView);
  
           username = itemView.findViewById(R.id.username);
           fullname = itemView.findViewById(R.id.fullname);
           image_Profile = itemView.findViewById(R.id.image_Profile);
           btn_follow = itemView.findViewById(R.id.btn_follow);
          }
      }
  
      private void isFollowing (final String userid, final Button button) {
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference()
                  .child("Follow").child(firebaseUser.getUid()).child("following");
          reference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  if (dataSnapshot.child(userid).exists()){
                      button.setText("following");
                  } else {
                      button.setText("follow");
                  }
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) {
  
              }
          });
      }
  }
  </code></pre>
  
  <p>I hope someone can help you</p>
  
  <p>Best Regard Tim schmitt</p>