I'm having issues getting data snapshots value and i believe its because I'm wanting to access a Hashmap<String,Hashmap>()
value. Is there a way for me to obtain all the data snapshot and put it into a class in my app?
Here's the sample error output:
W/System.err: com.google.firebase.database.DatabaseException:
Class java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead
Sample Code:
RootRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
try {
if(dataSnapshot.exists()){
GenericTypeIndicator<Users> u = new GenericTypeIndicator<Users>(){};
Users usersData = dataSnapshot.getValue(u);
}
}
}
}
Here's a screenshot of the realtime database.
This is my Users Class:
public class Users {
private String id, name, phone, email,points, upline;
private HashMap<String, String> downlines, orderHistory;
private HashMap<String, HashMap> transactions;
public Users(){
}
public Users(String id, String name, String phone, String email, String points, HashMap orderHistory, String upline, HashMap downlines, HashMap transactions) {
this.id = id;
this.name = name;
this.phone = phone;
this.email = email;
this.points =points;
this.orderHistory = orderHistory;
this.downlines = downlines;
this.upline = upline;
this.transactions = transactions;
}
The error indicates that I have issues on Users usersData = dataSnapshot.getValue(u);