How to Handle Offline Transactions in Firebase Realtime Database?
<p>I have an <code>addValueEventListener</code> which listens to any value changes in Firebase Realtime Database. In online mode, everything is working fine.</p>

<p>But in offline mode, device is offline and my Web Server has done multiple transactions on Firebase Realtime Database on same value for which I put the listener from Android. After the device comes online, it will only listen for the last transaction and skipping the other transactions done in between.</p>

<p>PFB reference <a href="https://firebase.google.com/docs/database/android/offline-capabilities#section-handling-transactions-offline" rel="nofollow">link</a>. PFB code which i have done so far:</p>

<pre><code>     FirebaseDatabase.getInstance().setPersistenceEnabled(false);
        FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
DatabaseReference myRef = firebaseDatabase.getReference("mykey");
        myRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                    HashMap&lt;String, Object&gt; key_Value = (HashMap&lt;String, Object&gt;) dataSnapshot.getValue();
                    for (String key : key_Value.keySet()) {
                        System.out.println("firebase key is "+key);
            }

            @Override
            public void onCancelled(DatabaseError error) {
                // Failed to read value
                Log.w("feroz ", "Failed to read value.", error.toException());
            }
        });
    }
</code></pre>