Mr Khan
Mr Khan

Reputation: 51

Firebase Database Not Working..No Response

I'm not be able to access the Database, means Its not giving me any response while I writing into the database. I don't have any Type of authentication just for temporary I use firebase but it's not allowing me to read and write into the database.

Is it compulsory to have the authentication to access the Database?

I also set up the database rules to the auth==null..

Still no response..

My Code :

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

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


        Button button=(Button)findViewById(R.id.bt);
        button.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        TextView textView=(TextView)findViewById(R.id.tv);
        DatabaseReference databaseReference= FirebaseDatabase.getInstance().getReference();
        databaseReference.child("User").setValue(textView.getText().toString());
    }
}

Upvotes: 4

Views: 10449

Answers (6)

Hamza khan
Hamza khan

Reputation: 1

If Firebase code is not responding ReDownload your Json file from firebase project and Replace it over old one.

Delete installed apks and run again.

Worked for me.

Upvotes: 0

akkmastr
akkmastr

Reputation: 224

If even rules are added and this problem is happening then your firebase location is not USA and you ll have to enter the databaseURL in getInstance(URL)

Upvotes: 0

saigopi.me
saigopi.me

Reputation: 14918

i also faced same problem 1 week after that i found a solution is OFF WIFI and TEST USING MOBILE DATA. it worked form me.

Upvotes: 2

Mr Khan
Mr Khan

Reputation: 51

Actually The issue I got that it's not working with my mobile data , but when I connect to a WiFi network firebase is working fine in android.. I checked my setting also but its all correct...

Upvotes: 1

Deepak Vardhan
Deepak Vardhan

Reputation: 92

Please check your Google Play Services version.

For firebase to work, it needs :-

  1. Android device with Google Play services 11.8.0 or above
  2. Android Studio version 2.2 or later
  3. Google Play Services from the Android SDK Manager
  4. Android Studio project and its package name

Make sure you are using all the right version of dependencies, check here Firebase Prerequisites

For now have these rules,

{
  "rules": {
     ".read": true,
     ".write": true
   }
}

And finally, make sure you are connected to internet because Google Play Services API does a download at the first time it is used.

Upvotes: 1

markharrop
markharrop

Reputation: 876

You need to set

Read == true
Write == true

Upvotes: 1

Related Questions