You can do the following: Get the firebase reference:
mDatabase = FirebaseDatabase.getInstance().getReference();
Then create the fields into which the data will be entered:
nomeEdit = (EditText) findViewById(R.id.field_nome);
sobrenomeEdit = (EditText) findViewById(R.id.field_sobrenome);
idadeEdit = (EditText) findViewById(R.id.field_idade);
Pick up what was typed in these fields:
final String nome = nomeEdit.getText().toString();
final String sobrenome = sobrenomeEdit.getText().toString();
final String idade = idadeEdit.getText().toString();
Then you can use a Map to enter the data typed in Edittexts.
private void SalvarDados(String userId, String nome, String sobrenome, String idade) {
String key = mDatabase.child("usuario").push().getKey();
Post post = new Post(userId, nome, sobrenome, idade);
Map<String, Object> postValues = post.toMap();
Map<String, Object> childUpdates = new HashMap<>();
childUpdates.put("/usuario-dados/" + userId + "/" + key, postValues);
mDatabase.updateChildren(childUpdates);
}
To display them, just create an Adapter in the main activity of your application.
guy didn’t work.
– Junior Machado
Sends all errors and log too.
– Adriano Oliveira