David Bowen David Bowen - 3 years ago 268
Java Question

Firebase:Failed to convert value of type java.lang.Boolean to String

Hi am trying to check in my database for a boolean of false, however I am getting an error of Failed to convert value of type java.lang.Boolean to String.

Structure of DB

Query q = databaseReference.child("Chatmessages").child(currentChatUser).child(userId);
ValueEventListener eventListener = new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
String true3 = "true";
for(DataSnapshot ds : dataSnapshot.getChildren()) {

public void onCancelled(DatabaseError databaseError) {}

Answer Source

Your comparison is wrong:


There's no way that the String value that you read will ever be true to the Boolean value false.

Either do a string to string comparison:


Or convert the string to a boolean first and then compare:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download