Firebase Security Rules permission denied
<p>My firebase database is something like this:-</p>

<p><a href="https://i.stack.imgur.com/vu9sQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vu9sQ.png" alt="enter image description here"></a></p>

<p>these are the security rules i have written but when i use them in simulator they validate just fine, but when used in code, give permission denied error</p>

<pre><code>{
  "rules": {
    "jokes" : {
      "textjokes" : {
        ".read" : true,
        ".write": "auth != null"
  }
},
  "users": {
  "$uid": {
    ".write": "$uid == auth.uid"
  }
},
 "userslikelist": {
  "$uid": {
    ".write": "$uid == auth.uid"
  }
}
}
</code></pre>

<p>}</p>

<p>I get error:-</p>

<p>/userslikelist/qzCqJph6XcZbiIpbDKTTxwjRHrh1/-KK850oXwPnOvxan1xNG failed: FirebaseError: Permission denied</p>

<p>/jokes/textjokes/MISC-0-01/likeCount failed: FirebaseError: Permission denied</p>

<p>My code:-</p>

<pre><code>Firebase ref = new Firebase("https://xxxxxxxxx.firebaseio.com/userslikelist/" + mAuth.getCurrentUser().getUid());
    ref.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
                if(!likedMap.containsKey(postSnapshot.getKey())){
                    likedMap.put(postSnapshot.getKey(), postSnapshot.getValue(String.class));
                }
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
</code></pre>

<p>I dont get it. what am i doing wrong?</p>

<p>Updated Code:-</p>

<pre><code>{
    "rules": {
        "jokes": {
            "textjokes": {
                ".read": true,
                ".write": "auth != null"
            }
        },
        "users": {
            "$uid": {
                ".write": "$uid == auth.uid"
            }
        },
        "userslikelist": {
            "$uid": {
                ".read": "$uid == auth.uid",
                ".write": "$uid == auth.uid"
            }
        }
    }
}
</code></pre>