Firebase在Android上启用离线功能

时间:2016-09-27 17:13:21

标签: android firebase firebase-realtime-database

我的应用程序无法脱机工作。我收到了这个错误:

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

0 个答案:

没有答案