Skip to content Skip to sidebar Skip to footer

Firebase Android Method To Check Existence Of User's Profile Info In Firebase Database

I don't get any error message but I want to execute code differently. If you check following java code, it runs like Tag:1 > Tag:2 > Tag:4 > Tag:5 > Tag:3. I want to ru

Solution 1:

From what I can see from your code is:

  • You already have the userID of the userProfile
  • You are checking whether a profile exists on that specific id or no.

Well, creating an object and checking whether its null or no is definitely one way but Firebase has a pre-defined method for checking whether data exists on that specific node or no:

dataSnapshot.exists()

Returns true if this DataSnapshot contains any data. It is slightly more efficient than using snapshot.val() !== null.

This is what the official docs mention.

Post a Comment for "Firebase Android Method To Check Existence Of User's Profile Info In Firebase Database"