我尝试从Firebase
获取数据并将其存储在ArrayList<Object>
中。为此,我创建了此方法:
private void getWholeListObject(int i, SellerObject soa) {
String userid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DocumentReference docRef = db.collection("Users").document(userid);
// Get the document, forcing the SDK to use the offline cache
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
// Document found in the offline cache
DocumentSnapshot document = task.getResult();
ArrayList<ShoppingListObject>shoppingLists = new ArrayList<>();
shoppingLists = (ArrayList<ShoppingListObject>) document.get("shoppingLists");
Log.i("asdf", "addNewDataToList: "+shoppingLists.get(i).getProducts());
addNewDataToList(i, shoppingLists, soa);
} else {
}
}
});
}
错误发生在日志上。
这是我的Object
班:
public class ShoppingListObject {
String listname;
ArrayList<String> products;
public ShoppingListObject() {
}
public ShoppingListObject(String listname, ArrayList<String> products) {
this.listname = listname;
this.products = products;
}
public String getListname() {
return listname;
}
public void setListname(String listname) {
this.listname = listname;
}
public ArrayList<String> getProducts() {
return products;
}
public void setProducts(ArrayList<String> products) {
this.products = products;
}
}
请找到我的Firestore
结构的附件: