replace() xóa Fragment hiện tại và thêm Fragment mới vào chỗ đó — khi back thì Fragment bị replace sẽ được tạo lại. add() giữ Fragment hiện có và chồng Fragment mới lên trên — khi back thì quay về Fragment cũ.
Dùng replace() để điều hướng giữa các màn hình, còn add() cho overlay như dialog hay bottom sheet.
replace() removes the current Fragment and adds a new one in its place — on back press the replaced fragment is recreated. add() keeps the existing Fragment and adds a new one on top — on back press returns to the existing fragment.
Use replace() for navigation between screens and add() for overlays like dialogs or bottom sheets.