firebase Firbase Realtime Database with Android How to connect Realtime database with Android Application


How to implement FirebaseRealTime database in android application. Following is the steps for do it.

  1. First install firebase sdk, If you dont know how to install then following is the URL for help. Install Firebase SDK

  2. After thet register your project in firbase console, URL of the firbase console is Firebase Console Url

  3. After successfuly complet above to step add following dependency in you application level gradel. compile ''

  4. Also one more thing configure your firebase database rules. If you dont how to configure then following is the URL which help you. Configure firebase Rules

  5. Now after all thing done, Original code is start, First retrieve your database instance throw FirebaseDatabase like following,

    FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("message");

You can now create different different object of DatabaseReference for the access different node,

  1. Now you can save or retrieve data using DataBaseReference like following way, For the save :

    myRef.setValue("Demo for Save");

Read data :

myRef.addValueEventListener(new ValueEventListener() {
    public void onDataChange(DataSnapshot dataSnapshot) {
        // This method is called once with the initial value and again
        // whenever data at this location is updated.
        String value = dataSnapshot.getValue(String.class);
        Log.d(TAG, "Value is: " + value);

    public void onCancelled(DatabaseError error) {
        // Failed to read value
        Log.w(TAG, "Failed to read value.", error.toException());

Note : This is the only introducation topic how to implement database in android application lost of more thing available in FirebaseRealtime database,