File not Found Exception When Using .getInputStream()
<p>Trying to use the following Code to download a remote hosted .apk file.</p>

<pre><code>package com.wireless.wmaa;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

public class UpdateApp extends AsyncTask&lt;String,Void,Void&gt;{
private Context context;
public void setContext(Context contextf){
    context = contextf;
}

@Override
protected Void doInBackground(String... arg0) {
      try {
            URL url = new URL(arg0[0]);
            HttpURLConnection c = (HttpURLConnection) url.openConnection();
            c.setRequestMethod("GET");
            c.setDoOutput(true);
            c.connect();

            String PATH = "/sdcard/Download/";
            File file = new File(PATH);
            file.mkdirs();
            File outputFile = new File(file, "Wireless.apk");
            if(outputFile.exists()){
                outputFile.delete();
            }
            FileOutputStream fos = new FileOutputStream(outputFile);

            InputStream is = c.getInputStream();


            byte[] buffer = new byte[1024];
            int len1 = 0;
            while ((len1 = is.read(buffer)) != -1) {
                fos.write(buffer, 0, len1);
            }
            fos.close();
            is.close();

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new                File("/sdcard/Download/Wireless.apk")), "application/vnd.android.package-archive");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag     android returned a intent error!
            context.startActivity(intent);


        } catch (Exception e) {
            Log.e("UpdateAPP", "Update error! " + e.getMessage());
        }
    return null;
}}  
</code></pre>

<p>And Here is the Code to start the Task:</p>

<pre><code>UpdateApp myApp = new UpdateApp();
myApp.setContext(getApplicationContext());
myApp.execute("http://some.domain.com/someSite/some.apk");
</code></pre>

<p>Able to connect but when trying to use the InputStream throws a file not found exception. I can browse to the file from the Android Default Browser and I am prompted to download the file which is the same functionality I would like in my App. Here is my manifest:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.wireless.wmaa"
    android:versionCode="1"
    android:versionName="1.0" &gt;

    &lt;uses-sdk android:minSdkVersion="10" /&gt;
    &lt;uses-feature android:name="android.hardware.camera" /&gt;
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;    
    &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
    &lt;uses-permission android:name="android.permission.DELETE_PACKAGES" /&gt;
    &lt;uses-permission android:name="android.permission.INSTALL_PACKAGES" /&gt;
    &lt;application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
                                         &gt;
        &lt;activity
            android:label="@string/app_name"
            android:name=".SelectServer" 
            android:theme="@android:style/Theme.NoTitleBar"
            android:screenOrientation="landscape" &gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt; 
            &lt;/intent-filter&gt;"
            &lt;/activity&gt;
        &lt;activity
            android:name=".UpdateApp"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar"
            android:screenOrientation="landscape" &gt;  
            &lt;intent-filter&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

        &lt;activity
            android:name=".WirelessActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar"
            android:screenOrientation="landscape" &gt;  
            &lt;intent-filter&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;


&lt;/manifest&gt;
</code></pre>
