I am trying to select image from gallery and code is working well on devices upto andorid nogut(7). I have added provider.xml also. This is my code
   public void processSelectionOfImage(int code) {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_PICK);
    Uri fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
    try {
        intent.putExtra("return-data", true);
        startActivityForResult(
                Intent.createChooser(intent, "Select Picture"), code);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
I am getting NullPointerException
  java.lang.NullPointerException: file
    at android.net.Uri.fromFile(Uri.java:453)
 
     
    