KOTLIN/FIREBASE Error when I try get data from firebase database - Client is offline

Matthew Kna

When i try get user information by his uid which is same like in firebase database this error is shown.

enter image description here

uid is passed in right way I have checked it. Route to database is good and I have checked this too.

Here is my code and this probably don't have any mistakes because everything work and only Firebase had some problems.

class Profil : AppCompatActivity() {

    private var fAuth: FirebaseAuth?=null
    private var database: DatabaseReference?=null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_profil)

        fAuth= FirebaseAuth.getInstance()

        // ✋ Here I checked with uid and uid.toString()

        var userCheck = fAuth!!.currentUser?.uid.toString()


        getData(userCheck)

        // ✋ Here I checked that good uid is get

        //tv_firsName.text = userCheck
    }

    private fun getData(userCheck: String) {

        database = FirebaseDatabase.getInstance().getReference("Users")
        database!!.child(userCheck).get().addOnSuccessListener{

            if(it.exists()){
                val firstName = it.child("firstName").value
                val lastName = it.child("lastName").value
                val position = it.child("position").value
                val email = it.child("email").value

                tv_Imie.text = firstName.toString()
                tv_Nazwisko.text = lastName.toString()
                tv_Stanowisko.text = position.toString()
                tv_Email.text = email.toString()
            }else{
                Toast.makeText(this, "User does not exist", Toast.LENGTH_SHORT).show()
            }
        }.addOnFailureListener{
            Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show()

            Log.e("firebase", "Error getting data", it)
        }
    }
}

Here is my database structure

enter image description here

I checked some ways to solve this problem.

I have seen some people propose a solution with addValueEventListener, but then the list is fetched. I want single user information to be included in my textViews. I read that the problem may be related to a bug in Firebase and not in the code.

Matthew Kna

Ok, problem was with Firebase not my application. I don't know why but when I started app in every try Firebase closed my connection with database. I tried add to google.services.json some links to database and change some settings but this didn't work. After all I removed app from firebase and delete file google.services.json. I added app again on website then I connect app with firebase and new google.services.json was set. That's all everything is working thanks for help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I get an error when I try to show the comments for each post

How to get Data from a Firebase Database and populate them in a ListView

How to get data from Firebase Database in a loop?

how to get data from firebase database?

Why I get error when I try to install pyaudio?

How to get the web pages from cache and restore data in the forms when i try to reach them from other pages of my site?

I try to get a football game schedule from Google and this error occurs

Firebase offline database

Lua: I get error when I try to run a script in Windows

I get a syntax error when I try to send a discord message

Is there a way to get rid of the syntax error when I run try and except?

Get data from google firebase realtime database web

Why do I get an Error when I try to rename a table after FROM?

Why I get an error when I try to upload a picture

ID get NULL when i try to update data

404 ERROR when I try to GET data from google spreadsheet

When I try to define settings, I get a different error

Android:App crashes when i try to retrieve data from intent

I cannot get the data from the Sqlite database

Getting an error when I try to parse data to get values from JSON

Why I get error when try build image in docker?

I try to get data from firebase and give me this error _CastError (Null check operator used on a null value)

When i try to get data from data for edit page it's showing me error

Flutter: Error: Instance of Object when I try to update user data

App crashes when I try to read data from Cloud Firestore

Read data from Firebase database when I have multiple unique ids

I try getting data from eBay from sold and auction items using webscraping but for some reason i get a NoneType error

Project freezes when I try to get data from api

I get data from Api but when I try to set the value with useState it give me an empty object

TOP Ranking

HotTag

Archive