Lo que pasa es que tengo un layout que muestra info de un usuario, sin embargo, tengo un código en el cual al darle click a este layout, este elimina la info del usuario en la base de datos de Firebase y este en vez de eliminar una vez los datos del usuario, continúa eliminando los datos aunque ya hayan sido eliminados, y en la base de datos muestra que sigue eliminando los datos como si siguiera ejecutando el código...
Este es el código:
ly1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Dialogo de alerta
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage("¿Quieres eliminar esta información?")
.setTitle("Consulta")
.setCancelable(false)
.setNegativeButton("Cancelar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setPositiveButton("Sí, continuar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
eliminar1();
}
});
AlertDialog alert = builder.create();
alert.show();
//Dialogo de alerta
}
});
public void eliminar1(){
Database.child("users").addValueEventListener(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.child(user_id).exists()) {
DatabaseReference UserDB = Database.child("users").child(user_id);
UserDB.child("País1").removeValue();
UserDB.child("Ciudad1").removeValue();
UserDB.child("TipodeEmpresa1").removeValue();
UserDB.child("UserEmp1").removeValue();
UserDB.child("TipoAtencion1").removeValue();
UserDB.child("Numero1").removeValue();
UserDB.child("Direccion1").removeValue();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
Database.child("users empresas").addValueEventListener(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.child(user_id).exists()) {
DatabaseReference EUserDB = Database.child("users empresas").child(user_id);
EUserDB.child("País1").removeValue();
EUserDB.child("Ciudad1").removeValue();
EUserDB.child("TipodeEmpresa1").removeValue();
EUserDB.child("UserEmp1").removeValue();
EUserDB.child("TipoAtencion1").removeValue();
EUserDB.child("Numero1").removeValue();
EUserDB.child("Direccion1").removeValue();
DatabaseReference EmpUserDB = Database.child("Empresas " + País).child(Ciudad)
.child(TipodeEmpresa).child(user_id);
EmpUserDB.child("País1").removeValue();
EmpUserDB.child("Ciudad1").removeValue();
EmpUserDB.child("TipodeEmpresa1").removeValue();
EmpUserDB.child("UserEmp1").removeValue();
EmpUserDB.child("TipoAtencion1").removeValue();
EmpUserDB.child("Numero1").removeValue();
EmpUserDB.child("Direccion1").removeValue();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
Esto es lo que ocurre en la Database de Firebase
Y el Logcat lo único que me arroja es esto:
I/Choreographer: Skipped 38 frames! The application may be doing too much work on its main thread.
I/art: Explicit concurrent mark sweep GC freed 156145(4MB) AllocSpace objects, 0(0B) LOS objects, 42% free, 16MB/28MB, paused 2.699ms total 129.416ms
I/art: Explicit concurrent mark sweep GC freed 151397(4MB) AllocSpace objects, 0(0B) LOS objects, 40% free, 17MB/29MB, paused 3.040ms total 157.930ms
I/art: Explicit concurrent mark sweep GC freed 157889(4MB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/30MB, paused 3.274ms total 148.011ms
I/art: Explicit concurrent mark sweep GC freed 156957(4MB) AllocSpace objects, 0(0B) LOS objects, 39% free, 18MB/31MB, paused 3.453ms total 153.131ms
I/Choreographer: Skipped 81 frames! The application may be doing too much work on its main thread.
I/art: Explicit concurrent mark sweep GC freed 152412(4MB) AllocSpace objects, 0(0B) LOS objects, 40% free, 19MB/32MB, paused 4.729ms total 160.107ms
I/art: Explicit concurrent mark sweep GC freed 150465(4MB) AllocSpace objects, 0(0B) LOS objects, 40% free, 20MB/33MB, paused 3.861ms total 172.896ms
I/art: Explicit concurrent mark sweep GC freed 163116(4MB) AllocSpace objects, 0(0B) LOS objects, 40% free, 21MB/35MB, paused 4.198ms total 191.875ms
I/art: Explicit concurrent mark sweep GC freed 180853(5MB) AllocSpace objects, 0(0B) LOS objects, 39% free, 22MB/36MB, paused 5.180ms total 194.496ms
I/art: Explicit concurrent mark sweep GC freed 186895(5MB) AllocSpace objects, 0(0B) LOS objects, 40% free, 23MB/38MB, paused 4.822ms total 207.796ms
I/art: Explicit concurrent mark sweep GC freed 177832(5MB) AllocSpace objects, 0(0B) LOS objects, 39% free, 23MB/39MB, paused 4.416ms total 219.217ms
I/Choreographer: Skipped 126 frames! The application may be doing too much work on its main thread.
I/art: Explicit concurrent mark sweep GC freed 186017(5MB) AllocSpace objects, 0(0B) LOS objects, 39% free, 24MB/40MB, paused 4.827ms total 214.308ms
I/art: WaitForGcToComplete blocked for 29.602ms for cause HeapTrim
I/art: Explicit concurrent mark sweep GC freed 199439(5MB) AllocSpace objects, 0(0B) LOS objects, 38% free, 25MB/41MB, paused 5.155ms total 236.598ms
I/art: Explicit concurrent mark sweep GC freed 194731(5MB) AllocSpace objects, 0(0B) LOS objects, 37% free, 26MB/42MB, paused 5.769ms total 244.224ms
I/art: Explicit concurrent mark sweep GC freed 188405(5MB) AllocSpace objects, 0(0B) LOS objects, 36% free, 27MB/43MB, paused 6.586ms total 252.006ms
I/art: Explicit concurrent mark sweep GC freed 201791(5MB) AllocSpace objects, 0(0B) LOS objects, 35% free, 28MB/44MB, paused 6.023ms total 262.258ms
I/Choreographer: Skipped 162 frames! The application may be doing too much work on its main thread.
I/art: Explicit concurrent mark sweep GC freed 208883(6MB) AllocSpace objects, 0(0B) LOS objects, 34% free, 29MB/45MB, paused 6.196ms total 268.874ms
I/art: Explicit concurrent mark sweep GC freed 203862(6MB) AllocSpace objects, 0(0B) LOS objects, 34% free, 30MB/46MB, paused 7.763ms total 277.918ms
I/art: Explicit concurrent mark sweep GC freed 216592(6MB) AllocSpace objects, 0(0B) LOS objects, 33% free, 31MB/47MB, paused 8.465ms total 294.595ms
I/art: Explicit concurrent mark sweep GC freed 214939(6MB) AllocSpace objects, 0(0B) LOS objects, 32% free, 32MB/48MB, paused 7.123ms total 300.286ms
I/art: Explicit concurrent mark sweep GC freed 218513(6MB) AllocSpace objects, 0(0B) LOS objects, 31% free, 34MB/50MB, paused 7.153ms total 314.664ms
I/art: Explicit concurrent mark sweep GC freed 213545(6MB) AllocSpace objects, 0(0B) LOS objects, 31% free, 35MB/51MB, paused 7.591ms total 321.990ms
I/art: Explicit concurrent mark sweep GC freed 224874(6MB) AllocSpace objects, 0(0B) LOS objects, 30% free, 36MB/52MB, paused 10.347ms total 352.826ms
I/Choreographer: Skipped 203 frames! The application may be doing too much work on its main thread.
I/art: Explicit concurrent mark sweep GC freed 221543(6MB) AllocSpace objects, 0(0B) LOS objects, 29% free, 37MB/53MB, paused 7.489ms total 353.758ms
I/art: Explicit concurrent mark sweep GC freed 228626(6MB) AllocSpace objects, 0(0B) LOS objects, 29% free, 38MB/54MB, paused 9.213ms total 373.558ms
I/art: Explicit concurrent mark sweep GC freed 238412(6MB) AllocSpace objects, 0(0B) LOS objects, 28% free, 40MB/56MB, paused 8.436ms total 378.300ms
I/art: Explicit concurrent mark sweep GC freed 250041(7MB) AllocSpace objects, 0(0B) LOS objects, 27% free, 41MB/57MB, paused 10.690ms total 395.786ms
I/art: Explicit concurrent mark sweep GC freed 229737(6MB) AllocSpace objects, 0(0B) LOS objects, 27% free, 42MB/58MB, paused 10.770ms total 412.705ms
I/art: Explicit concurrent mark sweep GC freed 242506(6MB) AllocSpace objects, 0(0B) LOS objects, 26% free, 43MB/59MB, paused 11.316ms total 419.269ms
no se me ocurre cuál puede ser el motivo de este error...
Espero puedan ayudarme, desde ya, muchas gracias por su tiempo y ayuda!