Advertisements

Write object to Firebase Realtime Database

        //Creating and initializing User class object
        User user = new User("user1234", "abc", "xyz", "First", "January", "2001");
        
        //Getting Instance of Firebase realtime database
        FirebaseDatabase databaseInstance = FirebaseDatabase.getInstance();
        
        //Getting Reference to a User node, (it will be created if not already there) 
        DatabaseReference userNode = database.getReference("User");
        
        //Writing the User class object to that reference
        userNode.setValue(user);