PackageManager has a hidden function called deletePackage (it can be called via reflection). But this requires android.permission.DELETE_PACKAGES permission. It doesn’t matter whether you own the application or not, you must obtain this permission. And this permission will not be granted to third-party applications.
So basically, you cannot uninstall the application, even if it is yours. This really makes sense, as the user must control key events such as installing and uninstalling applications. Imagine a user’s frustration if he or she simply installed an application from the market but cannot find it (or similar scenarios).
You should simply disable the application functionality with the correct message. It will be much more convenient.
source share