Invalid Uri failure when trying to install an apk file programmatically
<p>I am trying to install apk files I store in the assets of my app (that will be moved to a external URL in the future). The app is for rooted devices and has the superuser granted permission. I am developing the app for devices that we own so we don't care about security at all, in case you wonder. </p>

<p>I get this error:</p>

<pre><code>05-14 09:27:18.205: E/(24879): pkg: file:///android_asset/myfile.apk
05-14 09:27:18.205: E/(24879): Failure [INSTALL_FAILED_INVALID_URI] (0)
</code></pre>

<p>every time I try this. What am I doing wrong? Thank you very much.</p>

<pre><code>private void install() throws IOException {
        AssetManager assetManager = getAssets();
        String[] files = null;
        try {
            files = assetManager.list("");
        } catch (IOException e) {
            Log.e("tag", "Failed to get asset file list.", e);
        }
        for(String filename : files) {
            if (filename.endsWith(".apk")){
            InputStream in = null;
            try {
                  in = assetManager.open(filename);
                  Uri myuri = Uri.parse("file:///android_asset/" + filename);
                  String commands[]={"pm install " + myuri};
                  executeAsRoot(commands);
                } catch(IOException e) {
                    Log.e("tag", "Failed to copy asset file: " + filename, e);
                } 
            }
        }
    }
</code></pre>
