Firebase add new child with specified name

This is my database

enter image description here

  • <size> attribute not useful when using layer-list?
  • ADB push multiple files with the same extension with a single command
  • How to get the density of a screen?
  • How to send a string using NFC from a windows phone 8 to an android device
  • Facebook key hash does not match any stored key hashes
  • OpenGL ES 2.0 screen flickering
  • I’d like to add new users to database keeping that format. I’ve tried this:

       //Store data in database
        Firebase usersRef = ref.child("Users");
        Map<String, String> userData = new HashMap<String, String>();
        userData.put("Nombre", name);
        userData.put("Password", pass);
        userData.put("Confirmed", "FALSE");
        userData.put("Email", mail);
        usersRef = ref.child("Users").child(name);

    The problem is that whenever i add a new user, the previous one is overwritten. Thanks a lot.

    Related posts:

    How to use Holo.Light theme, and fall back to &#039;Light&#039; on pre-honeycomb devices?
    Android BOOT_COMPLETED not received when application is closed
    Why should a TypedArray be recycled?
    Is Secure.ANDROID_ID unique for each device?
    Android Fragments fundamentals: why? Is this conceptually wrong?
    How to Send/receive Data via bluetooth android phone to medical equipment having bluetooth
  • Spinning progress bar in every listview item
  • Build android with gradle, replace string each product flavor
  • Is there any difference between `ListView.invalidateViews()` and 'Adapter.notifyDataSetChanged()'?
  • android studio gradle server configuration
  • Android TaskStackBuilder startActivities opens a white screen and freezes sometimes on Samsung Galaxy S3
  • AutoCompleteTextView displays 'android.database.sqlite.SQLiteCursor@'… after making selection
  • 3 Solutions collect form web for “Firebase add new child with specified name”

    It happens because you are using:

    Firebase usersRef = ref.child("Users");

    In this way you will push the value in url/Users removing the previous value.

    Check the doc:

    Using setValue() will overwrite the data at the specified location, including any child nodes.

    To add a new user without removing the previous one , just remove this line:


    In this way you will push the value in url/Users/myName without overriding other values.

    Firebase Database Push

    [FirebaseDatabase mydb =][2] FirebaseDatabase.getInstance();
    DatabaseReference mDatabase = mydb.getReference().child("Dealers").child(dealerId).child("Stock").child(stockAddDate);
    Map<String, String> userData = new HashMap<String, String>();
    userData.put("Product_Name", productName);
    userData.put("Holding_Stock", holdingStock);
    userData.put("Primary_Stock", primaryStock);

    Just use “PUSH” before setValue.

    This worked for me. I am using model class instead of Hash

    mFirebaseDatabase = mFirebaseDatabase.child(name);
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.