content: package io.github.akueisara.inventoryapp;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.support.v4.app.ActivityCompat;
  
  public class PermissionUtils {
  
      public static final int MY_PERMISSIONS_READ_EXTERNAL_STORAGE = 0;
  
      public static void showPermissionDialog(final String msg, final Context context, final String permission) {
          AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);
          alertBuilder.setCancelable(true);
          alertBuilder.setTitle(context.getString(R.string.permission_title));
          alertBuilder.setMessage(msg + " " + context.getString(R.string.permission_message));
          alertBuilder.setPositiveButton(android.R.string.yes,
                  new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                          ActivityCompat.requestPermissions((Activity) context,
                                  new String[]{permission},
                                  MY_PERMISSIONS_READ_EXTERNAL_STORAGE);
                      }
                  });
          AlertDialog alert = alertBuilder.create();
          alert.show();
      }
  }
  