Offline Usage
Firebase database manages persistence, even if there is on on-line connection. Writes to the database are stored locally and sent to the server, after the apps is online again. Add this line to the onCreate() method in ActivityMain.
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
Test this by turning flight mode on in the emulator. There is no more coding needed to add off-line functionality. Read more