Prevent user to uninstall application from android phone I have Moto G5 Plus Android phone. I don't want to allow someone to uninstall the application from my android phone. The android phone allows to press on the application and drag it to delete icon and allow uninstallation. 
I want if someone does the same operation in my phone then before uninstall it ask password or pattern lock.

Thanks.
When a user tries to uninstall an app through the home launcher, Settings app, or through any third-party app, the system app Package Installer is invoked and user is asked to confirm the uninstallation. So the solution for you is to either disable that Package Installer app (or at least its component which is invoked for user confirmation) or find an app locker which can lock this system app. 

I tried some app locker apps and found that AppLock - Fingerprint can lock down Package Installer app. It even recommends it. From then on, anyone trying to uninstall an app would need to authenticate  with your preferred choice of authentication before proceeding to uninstall. At the risk of redundancy, this does take care  of uninstallation via Settings app too, as I explained the reason for it in the beginning. 

Note: app locker apps alike many privacy protector apps are notorious for floundering a user's privacy and shoving ads down the user's throat.