How to add new child in Firebase database Android

后端 未结 6 1434
说谎
说谎 2020-12-10 05:22

I\'m trying to add a new child using the DatabaseReference in my Firebase Android app. I\'m doing:

DatabaseReference mDatabase = F         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 05:52

    You cannot add anything to the database if you're not authorized. You can do one of the following:

    Either set this to your rules tab in firebase console:

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

    Or you must create an authentication first (try with email/pass) and create user with

    createUserWithEmailAndPassword(email, password)
    

    and then sign in with:

    signInWithEmailAndPassword(email, password)
    

    and you need to enable sign-in with email/pass in your console as well.

    And then you can write data to your database.

提交回复
热议问题