1
votes

I try save something to firebase Database from android.

I create DB in firebase, and connect project to firebase in android studio, as you can see on screenshot connection to firebase from android studio I type this code:

FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.setValue("Hello, World!");

In firebase I set rules: For cloud:

rules_version = '2';
service cloud.firestore {
match /databases/{database}/** {
allow read, write  }}

For realtime:

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

And nothing happens. I don't see "Hello, World!" in firebase console, I don't see ane warning and errors in android logcat. What I do wrong?

1
Since you're writing to the Firebase Realtime Database, the first set of rules you shared is meaningless (as is the google-cloud-firestore tag). I don't immediately see what's going wrong, but I highly recommend minimizing the scope of your question to maximize the changes someone can help. - Frank van Puffelen
In your Firebase project, check realtimedatabase to see anything is written or not. - MMG
May I know if you put the google json inside your apps? - Ticherhaz FreePalestine

1 Answers

-1
votes
//firebase console official link
https://console.firebase.google.com

//setup your project into firebase console
//add dependency to  build.gradle(Module:app) file

 dependencies{
    implementation 'com.google.firebase:firebase-database:19.2.1'
}

// reference of firebase official docs for dependency
https://firebase.google.com/docs/android/setup

//tutorial link (youtube)
https://www.youtube.com/watch?v=71H9-MRXYOE