Skip to content
Advertisement

Why Can’t read data From Database Firebase?

 mFirebaseInstance = FirebaseDatabase.getInstance();

        mFirebaseDatabase = mFirebaseInstance.getReference("Name");


        mFirebaseInstance.getReference("Name2").addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                Log.e(TAG, "App title updated");

                 appTitle = dataSnapshot.getValue(String.class);


                // update toolbar title

                textGrid.setText(appTitle);
                if (appTitle == "tt"){
                    Toast.makeText(getApplicationContext() ,"dsfsdf",Toast.LENGTH_LONG).show();
                }


            }

            @Override
            public void onCancelled(DatabaseError error) {
                // Failed to read value
                Log.e(TAG, "Failed to read app title value.", error.toException());
                Toast.makeText(getApplicationContext() ,"Error read Value",Toast.LENGTH_LONG).show();

            }
        });

I store name information that was working a few days ago and the information is stored on firebase Realtime, and now you don’t do it, and nothing goes to Database.

in my dependencies i Used

implementation 'com.google.firebase:firebase-database:20.0.2'

and in build Gradle (project)

 dependencies {

        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        classpath 'com.google.firebase:perf-plugin:1.3.1'
        classpath 'com.android.tools.build:gradle:4.0.0'
        classpath 'com.google.gms:google-services:4.3.0'
        classpath 'com.google.gms:google-services:2.0.0-alpha2'



    }

Advertisement

Answer

In comments we find a problem, you need to add another one SHA-1, or change existing one. Go to your project. then tap on your project and go to settings. in bottom, tap to add new fingerprint, or delete

step1

step2

Advertisement