Fragment and Firebase

1

I have an android app that uses firebase, everything is fine but when I try to remove a value from the base from a fragment my app stops (but it is deleted). I have tried eliminating the value from an activity and everything works normally. The problem lies in the fragment and I would like to know if anyone can help me with this. Thank you very much.

private void removeTrustedContact() {  
        //Get Firebase reference  
        database = FirebaseDatabase.getInstance();  
        usersRef = database.getReference(References.USERS_REFERENCE);

        //Get data session
        sharedPreferences = context.getSharedPreferences(References.USER_PREFERENCES, Context.MODE_PRIVATE);
        phone = sharedPreferences.getString("phone", "");

        Task<Void> result = usersRef.child(phone).child("trustedContacts").child(phoneContact).removeValue();
        if(result.isSuccessful()){
            Toast.makeText(context, "Bien", Toast.LENGTH_SHORT).show();
        }else{
            Toast.makeText(context, "Mal", Toast.LENGTH_SHORT).show();
        }
    }
    
asked by Jhan Yturregui 28.08.2017 в 03:48
source

0 answers