I have created a simple application and I wonder what are method of updating it directly from its interface. I want to create a script that checks for new updates and if any are found a button saying "Download new update" should be displayed. If the user clicks on it either the new version is downloaded from the server, the running instance is closed and the downloaded file (.apk) is executed (to be installed), or update the existing one as the application is running (maybe the Android API has something for that).
Well, I am asking for some references, links or some clues. I also must specify that I don't want the settings and other local data to be deleted when installing the new version.