0
I’m trying to delete a document, however the app simply closes itself. I’ve tried everything I know, but the error persists. I don’t understand why. The code itself is correct.
The general way is this:
/tutors/zqfcZEX1E4UFEaVcocR/pets
Has anyone seen similar mistake?
dbFirestore.collection("/tutores").document(mTutorID).collection("/pets").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
for (int i = 0; i<queryDocumentSnapshots.getDocuments().size(); i++){
String fotonome = queryDocumentSnapshots.getDocuments().get(i).get("foto_nome").toString();
StorageReference storageRef = firebaseStorage.getReference();
StorageReference petRefFoto = storageRef.child("pets/"+fotonome);
petRefFoto.delete();
queryDocumentSnapshots.getDocuments().get(i).getReference().delete();
}
StorageReference storageRef = firebaseStorage.getReference();
StorageReference tutorRefFoto = storageRef.child("tutores/"+mTutorFotoNome);
tutorRefFoto.delete();
dbFirestore.collection("/tutores").document(mTutorID).delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) { AbreLogin();
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getBaseContext(), "Ocorreu algum problema, NÃO foi possivel apagar as contas dos pets, tente novamente!", Toast.LENGTH_LONG).show();
}
});
Error happens when this root document is deleted:
dbFirestore.collection("/tutores").document(mTutorID).delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
AbreLogin();
}
});
The general way is this
/tutors/zqfcZEX1E4UFEaVcocR/pets
What record of log in Android Studio?
– Valdeir Psr
it does not give error message, it deletes the document, closes the Activity and even without any command it talks back to previous Activity which has a get with addSnapListener() it obviously from error by no longer having the document.... pq it still does read on a get with addSnapshotListener() from Activity that is no longer showing? what should I do???
– Rodrigo Costa