I am trying to update app after showing the alert dialog in my app. It is working fine below Android Oreo. Here is what I have tried till now
String ANDROID_PACKAGE = "application/vnd.android.package-archive";
                    File update_apk = new File(context.getFilesDir(), intent.getStringExtra("update_file"));
                    Intent notificationIntent;
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                        notificationIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
                        notificationIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                        notificationIntent.setDataAndType(
                                FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", update_apk),
                                ANDROID_PACKAGE);
                    } else {
                        notificationIntent = new Intent(Intent.ACTION_VIEW);
                        notificationIntent.setDataAndType(
                                Uri.parse("file://" + update_apk.getAbsolutePath()),
                                ANDROID_PACKAGE);
                    }
                    startActivity(notificationIntent);
How to show this app update dialog in the devices which are not rooted. Any help would be appreciated. Thanks in aadvance.
 
     
    