title: java.lang.SecurityException Not allowed to install apk from another android application
body: <p>I am developing an Android app in which I am trying to download from a location(a website) an apk, store it on the sd card and I want to install it on my device.</p>
  
  <p>However, I encounter the following error when trying to install the apk:
  java.lang.SecurityException: Caller is not allowed to install APKs</p>
  
  <p>Any suggestions on why the exception appears? </p>
  
  <p>For installing I do the following:</p>
  
  <pre><code>public static void installApk(ContentResolver contentResolver) {
      final ContentValues values = new ContentValues();
      values.put(APK_KEY, APK_NAME);
      values.put(PACKAGE_KEY, PACKAGE_NAME);
      values.put(APKS_DIR_PATH_KEY, Environment.getExternalStorageDirectory() + APKS_DIR_PATH + APK_NAME);
      try {
          contentResolver.insert(INSTALL_SINGLE_URI, values);
      } catch (SecurityException e) {
          //permission not granted
          Log.e(Utils.class.getSimpleName(), e.toString());
      }   }
  </code></pre>