package com.example.mortezasaadat.app66_offlinecapability;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class MainActivity extends AppCompatActivity {


    EditText edtData;
    Button btnSendData;


    FirebaseDatabase database;
    DatabaseReference databaseReference;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        edtData = (EditText) findViewById(R.id.edtData);
        btnSendData = (Button) findViewById(R.id.btnSendData);


        FirebaseDatabase.getInstance().setPersistenceEnabled(true);

        database = FirebaseDatabase.getInstance();
        databaseReference = database.getReference();


        databaseReference.keepSynced(true);



        btnSendData.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                databaseReference.setValue(edtData.getText().toString());


            }
        });


    }
}
