Firebase database value keeps changing instead of adding itself

Firebase database value keeps changing instead of adding itself

What I want to do is to first check whether there's a value in my Firebase database, if there isn't then add it. My database looks like this:

What I want to do is to first check whether there's a value in my Firebase database, if there isn't then add it. My database looks like this:

appnickname{
Strings{
    key : value
    key : value
    key : value

And my current code is this:

refference.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot n : dataSnapshot.getChildren()) {
                if (n.getValue().equals(string)) {
                    break;
                }
                refference.child("key").setValue(string);
            }
        }

    @Override
    public void onCancelled(@NonNull DatabaseError databaseError) {
    }
});

The problem with my current code is that it simply changes the string that exists under the same key instead of adding a new key/value combo. The good thing is that if it's the same value, nothing happens as far as I can see. How can I fix the bad thing?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios