How do I go through these ids that I generated through the push and I can get the value of this id pq in the future I will need to use for the time that the user clicks on a list I move from parameter that id to another screen so that I can load this piece of information there
finalFirebaseDatabasedatabase=FirebaseDatabase.getInstance();finalDatabaseReferenceref=database.getReferenceFromUrl("https://appassistencia-8e7b9.firebaseio.com/empresa");
ref.addChildEventListener (new ChildEventListener () {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
final String areaAtuacao = (String) dataSnapshot.child("areaAtuacao").getValue();
final String empresaCidade = (String) dataSnapshot.child("empresaCidade").getValue();
final String empresaEstado = (String) dataSnapshot.child("empresaEstado").getValue();
final String empresaImagem = (String) dataSnapshot.child("empresaImagem").getValue();
final String empresaNome = (String) dataSnapshot.child("empresaNome").getValue();
I am getting the id aq with the String s, but the first time it comes null and with an id less at the end.
System.out.println(s);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://appassistencia-8e7b9.appspot.com/imagens").child(empresaImagem);
try {
final File localFile = File.createTempFile("images", "png");
storageRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Log.e("Test", "success!");
bitmap = BitmapFactory.decodeFile(localFile.getAbsolutePath());
items.add(new Empresa(empresaNome, areaAtuacao, empresaCidade, empresaEstado, bitmap));
}
});
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(s);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}});
recycler.setAdapter(new EmpresaAdapter(items, new EmpresaAdapter.OnItemClickListener() {
public void onItemClick(Empresa item) {
startActivity(new Intent(EmpresaActivity.this, Activity_Tab_Empresa.class));
}
}));
}}