com.google.firebase.database.DatabaseException: Failed to convert value of type java.lang.Long to String
is the error I keep getting w
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.
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;
If you want to access data directly without create any object, You can change datatype with String to long.class
`String reward = ds.child("reward").getValue(String.class);`
to
`long reward = ds.child("reward").getValue(long.class);`
or
public String reward;
to
public long reward;
Try adding quotes ("
) around the numbers:
For example mobile_phone = "1234"
instead of mobile_phone = 1234
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
for get value retrieve in firebase database
Edit all the DB entries by adding double quote like "phone" : "900000000"
and it will solve the problem, so e.g.:
"phone" : 900000000
"name" : "xxxx",
"password" : 111111
changed to:
"phone" : "900000000",
"name" : "xxxx",
"password" : "111111"