Insert data and "primary key" in Firebase

2

Good morning,

I'm starting with programming, and I have the following question. 1. I can enter data in the firebase, but when I try to insert it again, only replacing the data occurs instead of inserting the new record.

  • How can I enter data in the firebase together with the "primary key"? (field highlighted in the image, it's just to display the field I want, it's not my bank in the firebase).
  • Imageofbankonfirebasewithfield"primary key" Hugs.

        
    asked by anonymous 30.08.2017 / 14:42

    1 answer

    0

    Try this.

    DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
     mDatabase.child("tasks").push().setValue(firebaseData, new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
                //Problem with saving the data
                if (databaseError != null) {
    
                } else {
                    //Data uploaded successfully on the server
    
                   }
    
                }
        });
    
        
    30.08.2017 / 20:58