I am new to android and i have been searching the web from last two days for this. I found following links too but i am not getting how and where to implement this code to start automatic installation of the apk file after it downloads completely and how to delete the downloaded apk file after installation. Please help me by guiding me the right way.

[how to install apk file programmatically](https://stackoverflow.com/questions/5428853/how-to-install-apk-file-programmatically)

[Invoking activity from APK in another android application](https://stackoverflow.com/questions/2702178/invoking-activity-from-apk-in-another-android-application)

[Android install apk programmatically](https://stackoverflow.com/questions/4768930/android-install-apk-programmatically)

[Install APK programmatically on android](https://stackoverflow.com/questions/6362479/install-apk-programmatically-on-android)

<http://www.anddev.org/viewtopic.php?p=23928>

EDIT :

i have written this code in manifest file :

```
<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <!-- <uses-permission android:name="android.permission.INSTALL_PACKAGES"/> -->
    <application android:icon="@drawable/biz_logo"
        android:permission="android.permission.WRITE_CONTACTS">
        <activity android:name="com.biz.mlm.Main">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="content" />
                <data android:scheme="file" />
                <data android:mimeType="application/vnd.android.package-archive" />
            </intent-filter>
        </activity>

```