Eu estou tentando isso, mas sempre aparece que o app parou de funcionar.
public class TesteActivity extends AppCompatActivity {
private TextView la;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.teste);
la = (TextView) findViewById(R.id.txtavisoteste);
DatabaseReference dref = FirebaseDatabase.getInstance().getReference().child("usuario");
dref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String value = dataSnapshot.getValue(String.class);
la.setText(value);
}
@Override
public void onCancelled(DatabaseError error) {
Toast.makeText(TesteActivity.this, "Erro: " + error.toException(), Toast.LENGTH_SHORT).show();
}
});
}
}