Recently I started testing Firebase new document db Firestore for learning purpose, I am stuck right now to access the values store inside the document as object.
I am using the below code to access object Privacy
stored in document, but I am not sure how to access the Key - Value
? For Example I have 3 sub Key - Value
pair in the object, how will I access and edit it individually?
DocumentReference docRef = FirebaseFirestore.getInstance().collection("Users").document("PQ8QUHno6QdPwM89DsVTItrHGWJ3");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
Log.d(TAG, "DocumentSnapshot data: " + task.getResult().getData().get("privacy"));
Object meta_object = task.getResult().getData().get("privacy");
} else {
Log.d(TAG, "No such document");
}
} else {
Log.d(TAG, "get failed with ", task.getException());
}
}
});
Any help is appreciated, thanks.