You need to write data to the firebase database. I use the code from the documentation

FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("*****"); myRef.push().setValue(*****); 

So I set the value of the key, but how to set the name? The default is random, as far as I understand. Which operator performs such a function?

    1 answer 1

    The push () operator is used so that the system itself generates a random ID.

     // Генерируем референс для нового места и добавления данных DatabaseReference pushedPostRef = postsRef.push(); // Получаем уникальный айди сгенерированный методом push() String postId = pushedPostRef.getKey(); 

    To add your own keys to the database, send something like this:

     DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference(); databaseReference.child("users_models").child("my_user_1").setValue(userModel); 

    If there is no such key in the database, the system will create the first record itself.