The data is already saved on the Firestore but I can't get it. Also, the created list size is still equal to null.
I know I suppose to get data from existUserProfileModelList and not from existUserProfileModel but I don't know how to do it. This my code:
public class UserProfileActivity extends AppCompatActivity {
// created List from User Profile Model
private List<ExistUserProfileModel> existUserProfileModelList;
// define some Edit texts
private EditText profile_phone_ET, profile_FullName_ET, profile_Address_ET;
// define FireStore
private FirebaseFirestore firestore;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
profile_phone_ET = findViewById(R.id.profile_Phone);
profile_FullName_ET = findViewById(R.id.profile_FullName);
profile_Address_ET = findViewById(R.id.profile_Address);
firestore = FirebaseFirestore.getInstance();
existUserProfileModelList = new ArrayList<>();
firestore.collection("UserData").document().collection(profilePhone)
.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
ExistUserProfileModel existUserProfileModel = document.toObject(ExistUserProfileModel.class);
existUserProfileModelList.add(existUserProfileModel);
profile_FullName_ET.setText(existUserProfileModel.getUserName());
profile_Address_ET.setText(existUserProfileModel.getUserAddress());
}
Log.i("Size ", String.valueOf(existUserProfileModelList.size()));
}
else{
Toast.makeText(UserProfileActivity.this, "Error" + task.getException(), Toast.LENGTH_SHORT).show();
}
}
});

