Update : recyclerview , detail
How can I retrieve children underlined by red !! I want to display it in RecyclerView.
This is the code how I save data in Firebase :
long OrderNum = 1;
DatabaseReference newPost = reference.child(refernce);
newPost.child("refernce").setValue(refernce);
newPost.child("nompdv").setValue(nompdv);
newPost.child("etat").setValue(etat);
newPost.child("datecommande").setValue(datecommande);
newPost.child("user_id").setValue(uid);
newPost.child("produitcommande"+ OrderNum++).setValue(produitcommande);
Since you can have multiple produitcommande1, produitcommande2, and so on, a more feasible structure would be to add the products in Map, as seen below:
Firebase-root
|
--- commande
|
--- KAKJQBUX
|
--- datecommande: "10-11-2021 15:15"
|
--- produitcommande
|
--- D2: true
|
--- D3: true
In this way, you can add as many products as you want. To read them, simply get the node as a Map object and integrate it through the records and only get the keys. If you want to have the produitcommande
as a field in a class, then simply add it as a Map<String, Object>.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.