我的应用程序无法脱机工作。我收到了这个错误:
myRef = No such instance field: 'myRef'
myValueEventListener = No such instance field: 'myValueEventListener'
即使我已经设置:
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
有没有人有想法?
代码:
database = FirebaseDatabase.getInstance();
myRef = database.getReference("lifts");
myRef.keepSynced(true);
myValueEventListener = myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot item : dataSnapshot.getChildren()) {
lift = item.getValue(Lift.class);
lift.key = dataSnapshot.getKey();
arrayLifts.add(lift);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
#askFirebase