title: Permission Denied Error in Android Studio & Firebase
body: <p>I am a beginner to Android and got stuck at a problem stating "Firebase permission denied error". Following is my code snippet:  </p>
  
  <pre><code>private void searchUser() {
          Log.d(Constants.TAG, "GetUser:  userId " + mFirebaseUser.getUid()+"   mFirebaseUser.getPhoneNumber()  " +mFirebaseUser.getPhoneNumber());
  
          if (!TextUtils.isEmpty(mFirebaseUser.getUid())) {
              showSnackBar(getString(R.string.fetching_profile_details), false);
              Utils.showProgressDialog(mActivity, false);
  
              final FirebaseDatabase database = FirebaseDatabase.getInstance();
              DatabaseReference userRef = database.getReference(Constants.FIREBASE_USERS);
              Query query = userRef.orderByChild(Constants.FIREBASE_USER_PHONE)
                      .equalTo(mFirebaseUser.getPhoneNumber())
                      .limitToFirst(1);
  
             query.addListenerForSingleValueEvent(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      Utils.hideProgressDialog();
                      if (dataSnapshot != null &amp;&amp; dataSnapshot.exists() &amp;&amp; dataSnapshot.getChildrenCount() &gt; 0) {
                          //Found user with same number
                          //Log.d(Constants.TAG,"dataSnapshot  " +dataSnapshot);
  
                          for(DataSnapshot childDataSnapshot : dataSnapshot.getChildren()) {
                              //Log.d(Constants.TAG, "childDataSnapshot  " + childDataSnapshot);
                              mUser = childDataSnapshot.getValue(com.hypertrack.wintry_consumer.models.User.class);
                          }
  
                          if (mUser != null) {
                              isNewUser = true;
                              preFillData();
                          }
                      }
                  }
  
                  @Override
                 public void onCancelled(DatabaseError databaseError) {
                      Utils.hideProgressDialog();
                      Log.e(Constants.TAG, "onCancelled", databaseError.toException());
                      showSnackBar("Firebase Error finding User details: " + databaseError.getMessage());
                  }
              });
          } else {
              showSnackBar("No firebase user available ");
          }
      }
  </code></pre>
  
  <p>Following is my cloud firestore rule:-</p>
  
  <pre><code>service cloud.firestore {
    match /databases/{database}/documents {
      match /{document=**} {
        allow read, write;
      }
    }
  }
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <blockquote>
    <p>"Firebase Database Error: Permission denied"</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/qI1rJ.png" rel="nofollow noreferrer">Android Studio Screenshot</a></p>
  
  <p>Please help with its solution.</p>