【发布时间】:2022-06-13 22:43:37
【问题描述】:
为什么 Firebase onChildAdded 函数的调用频率与 DB 中的条目一样频繁? 我以为只有在添加新对象时才会调用此方法
@Override
//Have already tried the call in onCreate, same problem
protected void onStart() {
ref.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
//Called up for each entry, currently 7x
List<Places> testPlaces = new ArrayList<Places>();
for(DataSnapshot snap : snapshot.getChildren())
{
testPlaces.add(snap.getValue(Places.class))
}
}
我也买了一个:
com.google.firebase.database.DatabaseException:无法将 java.lang.String 类型的对象转换为 com.bkoubik.fortestingall.Places 类型
【问题讨论】:
标签: java android firebase android-studio