1. Complete the Installation and setup part to connect your app to Firebase.

This will create the project in Firebase.

  1. Add the dependency for Firebase Realtime Database to your module-level build.gradle file:

compile ‘com.google.firebase:firebase-database:10.2.1’

  1. Configure Firebase Database Rules

Now you are ready to work with the Realtime Database in Android.

For example you write a Hello World message to the database under the message key.

// Write a message to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");

myRef.setValue("Hello, World!");