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.
However, I encounter the following error when trying to install the apk: java.lang.SecurityException: Caller is not allowed to install APKs
Any suggestions on why the exception appears?
For installing I do the following:
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());
} }