【发布时间】:2021-02-03 13:34:08
【问题描述】:
我想获取 firebase firestore value 的值,但我不断收到错误,有没有办法在不添加“”的情况下检索这些值?
DocumentReference documentReference = fStore.collection("Users").document(UserID);
documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot value, @Nullable FirebaseFirestoreException error) {
assert value != null;
mBankBalance.setText(""+ value.getDouble("Balance"));
}
});
每当我删除双引号时,mBankBalance.setText(""+value.getDouble("Balance")) 行就会出错。有没有办法只获取值?
【问题讨论】:
-
你能不能解释一下为什么我总是出错,或者是否可以只使用 value.getDouble()?
-
如果应用程序崩溃,会有一个堆栈跟踪。请在 logcat 上查找,并将其添加到您的问题中。请编辑您的问题并将您的数据库结构添加为屏幕截图。请回复@AlexMamo
标签: java android google-cloud-firestore