I want to read each Object list from the document "list_of_clients" and export it to a custom List that i created
In Realtime Database there is a function called
GenericTypeIndicator
which helps you getting the values, this is similar to what i want but on Cloud FireStore there is no such function
I'm very new to android and i don't know how much more i can explain this
but here are some pics:
This is my DataBase:
This is my user_list.java
private String user_addr;
private String user_name;
private String user_phone;
public user_list(String user_addr, String user_name, String user_phone) {
this.user_addr = user_addr;
this.user_name = user_name;
this.user_phone = user_phone;
}
public user_list() {
}
public String getUser_phone() {
return user_phone;
}
public void setUser_phone(String user_phone) {
this.user_phone = user_phone;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_addr() {
return user_addr;
}
public void setUser_addr(String user_addr) {
this.user_addr = user_addr;
}
What i tried:
db.collection("clients").document("list_of_clients")
.get()
.addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
//if read successful
DocumentSnapshot document = task.getResult();
List<user_list> messages = document.getData();
Toast.makeText(getApplicationContext(), document.getId() + " => " + document.getData(), Toast.LENGTH_LONG).show();
} else {
//eroare
}
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…