RT DB Callback

Advertisements
//Writing data and using call-back functions
documentReference.set(user).addOnCompleteListener(new OnCompleteListener<Void>() {
    @Override
    public void onComplete(@NonNull Task<Void> task) {
        if (task.isSuccessful()) {
            //Tas was successful
            Toast.makeText(MainActivity.this, "User Added", Toast.LENGTH_SHORT).show();
        }else{
            //Something went wrong
            Log.e(TAG, "onComplete: Error: " + task.getException().getLocalizedMessage() );
            
        }
    }
});