I can not delete the items I have in an array with the following code, trying two ways but nothing happened to the image of the bbdd and the code.
Maybe it's doing it with onDataChange ???
public void deleteEvent(View view) {
databaseReference = FirebaseDatabase.getInstance().getReference("Users").child( uiD ).child( "events" ).child( code );
databaseReference.removeValue();
users.getevents().remove( 1 );
}
Code for the entry in the array
public boolean checkAdd(String codigo ){
for ( String item : users.getevents()){
if(codigo.equals(item)){
return false;
}
}
return true;
}
if(checkAdd(codigo)){
users.getevents().add(codigo);
}
and then you get it from firebase
mDatabase = FirebaseDatabase.getInstance (). getReference (). child ("Events") .child (code);
mDatabase.addValueEventListener( new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Event event = dataSnapshot.getValue( Event.class );
mTitle.setText( event.getTitle() );
mDescription.setText( event.getDescription() );
dataEvent=event.getDateEvent();
code=event.getCode();
url=event.getFoto();
mCode.setText(event.getCode());
ano=event.getAno();
mes=event.getMes();
dia=event.getDia();
countDate();//diferencia fechas
url();//foto evento
}
@Override
public void onCancelled(final DatabaseError databaseError) {
}
} );