I am having trouble retrieving hash map values from Firestore. I have no trouble in uploading the values, but I am having difficulty in retrieving them.
Here are my constructors:
public class OrderItems {
private String uid;
private String product;
private int qty;
private int price;
private int totalPrice;
public OrderItems(){
}
public OrderItems(String uid, String product, int qty, int price) {
this.uid = uid;
this.product = product;
this.qty = qty;
this.price = price;
}
public String getUid() {
return uid;
}
public String getProduct() {
return product;
}
public int getQty() {
return qty;
}
public int getPrice() {
return price;
}
public int getTotalPrice() {
return qty * price;
}
public void setTotalPrice(int totalPrice) {
this.totalPrice = totalPrice;
}
}
My hash map constructor:
public class OrderObject {
private HashMap<String, OrderItems> orders;
public OrderObject(){
}
public OrderObject(HashMap<String, OrderItems> orders) {
this.orders = orders;
}
public HashMap<String, OrderItems> getOrders() {
return orders;
}
}
How do I store the objects using a constructor through an array list? And how can I access the individual fields afterwards? Thank you!