这是我的代码。但不工作。我得到空值。
我只想获取纬度经度值..
mLocationRef = FirebaseDatabase.getInstance().getReference().child("districsubdepot").child("Jaffna");
mLocationRef.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Double lt = (dataSnapshot.child("latitude").getValue(Double.class));
Double lo=(dataSnapshot.child("logitude").getValue(Double.class));
Toasty.success(getApplicationContext(), "value" + lt+lo).show();
}
}
最后我想使用这些纬度经度绘制折线。如何做到这一点?
最佳答案
除非使用多个查询,否则您无法获取部分值。 Firebase 将数据存储为(并且行为类似)一个大 json 文件。这意味着它尊重 json 标准。
在标准 json 中,除非使用高级标准和技术(例如 jsonpath),否则无法检索绑定(bind)到多个键的数据。
关于java - 如何获得这个firebase值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49901813/