Reinstall an app programmatically

Hello, I want to uninstall my kodular app programmatically and then install a newer version.
I know already how to install but I don’t know how to uninstall.
Is there any way?

I am using POCO F1 Android 10.

I think there is no need to uninstall previous version.
Simply install new version and it will replace older one.