I am trying to get a selected image uri into my cart database. I have tried to extend an activity from another, but I wasn't sure, and I got an error. here is where I stored all products in ProductActivity.
private void SaveProductInfoToDatabase()
{
ProductsRef = FirebaseDatabase.getInstance().getReference().child("Products");
...
HashMap<String, Object> productMap = new HashMap<>();
productMap.put("description", Description);
productMap.put("image", downloadImageUrl);
productMap.put("price", Price);
productMap.put("pname", Pname);
here is what I did to get image in the other activity
.
.
final DatabaseReference cartMap = new HashMap<>();
cartMap.put("pname", productName.getText().toString());
cartMap.put("price", productPrice.getText().toString());
cartMap.put("image", SellerAddNewProductActivity.downloadImageUrl);
}
I got this error in both activities:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference.
Can someone help me please? I am still learning.