Kotlin and Firebase Read and Write Data

Kotlin and Firebase read and write data

Try this code:

    val database = Firebase.database
val reflatitude = database.getReference("/user/time/$currenttime/latitude")
reflatitude .addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot){
val latitude= dataSnapshot.getValue<Double>()
}
override fun onCancelled(error: DatabaseError) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException())
}
}

Unable to write data on realtime database of firebase using kotlin

I created another similar project and it worked out for me. I don't know the problem in my project but now my new project is working fine.

firestore read and write from another app android [Kotlin]

I have Solved this problem, now i want some suggestion
heres the code in Buyer App.

val option  = FirebaseOptions.Builder()
.setProjectId("project-id-3564") //seller app project id
.setApiKey("Api_key")// api key of seller app project
.setApplicationId("1:1234567890")//app id for seller app project
.build()

val app = Firebase.initialize(this , option, "secondary")

val firebase = FirebaseFirestore.getInstance(app)
firebase.collection("collection").get().......

and also i have to change read write permission to the seller app project database rule

match /{document=**} {
allow read, write: if request.auth != null;
}

to this

match /{document=**} {
allow read, write: if true;
}

**
Again i got permission denied error

Which is not recomended.so Now what should i do about giving
permission

**

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

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.



Related Topics



Leave a reply



Submit