我在执行代码时遇到了这个问题
原因:java.lang.IllegalArgumentException:无效的文档引用。文档引用必须具有偶数个段,但用户必须具有1
我已经使用SharedPreferences来引用用户ID
该怎么办才能纠正错误。
private void saveUserData(){
CollectionReference ref = FirebaseFirestore.getInstance().collection("users");
DocumentReference documentReference = ref.document(sp.getUserId());
documentReference.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@javax.annotation.Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
String name = documentSnapshot.getString(Constants.NAME);
String profilepic = documentSnapshot.getString(Constants.PROFILE_PIC);
String email = documentSnapshot.getString(Constants.EMAIl);
sp.setUserData(Constants.NAME, name);
sp.setUserData(Constants.PROFILE_PIC, profilepic);
sp.setUserData(Constants.EMAIl, email);
}
});
}