Como evitar a substituição de dados no firebase
Este é o meu código para adicionar registros no Firebase. há variável externa chamada restauCount com valor (int) como 1
public void sendMessage(){
int restauCount = 1;
String identifier ="Restaurant" + restauCount;
Firebase userRef = firebaseRef.child("Caloocan");
EditText nameInput = (EditText) findViewById(R.id.nameTxt);
String name = nameInput.getText().toString();
EditText locInput = (EditText) findViewById(R.id.locationTxt);
String location = locInput.getText().toString();
EditText typeInput = (EditText) findViewById(R.id.typeTxt);
String foodtype = typeInput.getText().toString();
if (!name.equals("")){
Map<String, String> caloocan = new HashMap<String, String>();
caloocan.put("resname", name);
caloocan.put("resloc", location);
caloocan.put("foodtype", foodtype);
Map<String, Map<String, String>> users = new HashMap<String, Map<String, String>>();
users.put(identifier,caloocan);
userRef.setValue(users);
restauCount++;
}
}
Quando executo o sendessage () novamente. digitarei nos campos e, quando clicar em ADICIONAR, que é o sendMessage, ele será adicionado ao FireBase, no entanto, quando adicionar novos dados. SUBSTITUI OS DADOS ANTIGOS INPUTADOS? COMO POSSO ADICIONAR DADOS MÚLTIPLOS NO FIREBASE SEM SUBSTITUIR OS DADOS? O restauCount foi criado para aumentar o número de restaurantes inseridos,