Skip to content
Advertisement

Display data from user uid with Firebase Database

I want to recover data from the uid and then display them in RecyclerView.

I managed to recover the child/parent under Withdrawal thanks to the uid.

This is what it looks like in Java:

JavaScript

String id = ... retrieves the child value.

So far everything is fine except when I add this under the String id = ... :

JavaScript

I have this error appearing in my Logcat :

JavaScript

And finally here is my WithdrawProfile :

JavaScript

My database :

JavaScript

Thank you for your time

Advertisement

Answer

The problem is in reading this value from the database:

JavaScript

In your Java class you define prize as an int:

JavaScript

But in your database it is stored as a string value: "1000". Since they’re not the same type, Firebase can’t read the prize value and throws an error.

The solution is to either store the prize as a (whole) number:

JavaScript

Or to make it a string in your Java code too:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement