I am using this code to add new item to Firebase on Android. However, if somebody tried to add another item with the same key, it will replace the current item! How can I prevent this from happening? I mean like regular database; I want to use key as my primary key and not allow any item with same key to be added (or to replace another existing item)
myFirebaseRef.child(key).setValue(item, new Firebase.CompletionListener()
{
@Override
public void onComplete(FirebaseError firebaseError, Firebase firebase)
{
}
});
I don't want to use push() though because the keys have meaning in my app and I want to maintain there uniqueness