Switching between fragments in drawer menu does nothing

I am really new to android and I am really frustrated with it. I want to switch between fragments in drawer menu. However, the screen stays the same. In the drawer it says that I am on a particular fragment but I see no change. I set a different background to differentiate between them.

I believe that fragment manager is deprecated based on what people are saying but I don’t know how to change it with. Also the thin is I don’t know which tutorials are out of date because I have very little knowledge about android development.

Fragment code:

public class ToolsFragment extends Fragment {

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_tools, container,false);
}

}

Main activity code:

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private DrawerLayout drawer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    drawer = findViewById(R.id.drawer_layout);
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open,R.string.navigation_drawer_close);

    drawer.addDrawerListener(toggle);
    toggle.syncState();

    if (savedInstanceState == null) {

        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new CharacterFragment());
        navigationView.setCheckedItem(R.id.nav_characters);
    }


}

@Override
public void onBackPressed() {
    if (drawer.isDrawerOpen(GravityCompat.START)){
        drawer.closeDrawer(GravityCompat.START);
    } else{
        super.onBackPressed();
    }
}


@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()){
        case R.id.nav_characters:

            getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new CharacterFragment());
            break;
        case R.id.nav_episodes:
            getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new EpisodesFragment());
            break;
        case R.id.nav_tools:
            getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new EpisodesFragment());
            break;
    }
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

}

Answer

You forgot to call commit()

getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new CharacterFragment()).commit();