android – Firebase DatabaseException: Failed to convert value of type java.lang.Long to String

android – Firebase DatabaseException: Failed to convert value of type java.lang.Long to String

The problem is that you are creating the property mobile_phone as a String and on Firebase it is a Long type.

Change:

private String mobile_phone;

To:

private Long mobile_phone;

Problems

  1. If you are adding values in firebase database manually, the values will be in long data type; for example:

enter

  1. If you are adding values by commands, the values will be saved in the database as string.

Solution:

When you are getting the values from database, save the values in default data type. Then, when you want to reuse the value change it into the string by using the toString() method.

android – Firebase DatabaseException: Failed to convert value of type java.lang.Long to String

Check if your getters and class/model are equals in firebase database.

When method .getValue() retrieve datas it compare if signatures are same.

example:
In class we have a getLong
enter

for get value retrieve in firebase database
enter

Leave a Reply

Your email address will not be published. Required fields are marked *