I want to prevent user from uninstalling my application.But my main objective is to ask the password before uninstallation of the applcation.
same as App Lock app.
Nope, it is not possible.
But there are some security apps like antivirus apps that needs the Device Administration permission.
check this for more details Android Device Administration Permission
Which will not allow any 3rd party apps meddling with that app, so if you want to uninstall that app, you have to go to your settings remove it's Device Administration permission and then uninstall it.
but what about "appLock" ?
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies