0
將新值設置爲firebase數據庫(在firebase控制檯上檢查),但在查詢數據快照上檢索舊值。關於查詢firebase數據庫datasnapshot retrives舊值
final Query query = FirebaseDatabase.getInstance().getReference(DEVICES_TABLE).orderByChild("deviceUniqueId").equalTo(deviceUniqueId);
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Device device;
if (dataSnapshot.getChildren().iterator().hasNext()) {
device = dataSnapshot.getChildren().iterator().next().getValue(Device.class);
if (device.getIsEnable() == 1) {
loginView.onError(loginView.getContext().getString(R.string.error_device_disable));
doCyberoamLogout(mUserName, location);
} else {
switch (mMessage) {
case CYBEROAM_LOGIN_SUCCESS_MESSAGE:
//login successful
Toast.makeText(activity, "Cyberoam login success.", Toast.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
getEmailUsingCyberoamId(mUserName, mPasswod);
}
}, 5000);
break;
case CYBEROAM_WRONG_PASSWORD:
signOutFromFirebase();
loginView.onError(CYBEROAM_WRONG_PASSWORD);
break;
case CYBEROAM_MAX_LOGIN_LIMIT:
signOutFromFirebase();
loginView.onError(loginView.getContext().getResources().getString(R.string.prompt_max_login_limit));
break;
default:
signOutFromFirebase();
loginView.onError(loginView.getContext().getResources().getString(R.string.action_cyberoam_login_failed));
break;
}
}
query.removeEventListener(this);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
你可以發佈你的代碼嗎? –
你確定你正在獲取更新的數據嗎?而不是在更新或設備有正確的互聯網連接來加載新數據而不是來自緩存的數據庫信息之前 –
是否啓用了持久性? – Pipiks