Q:

Accessing and using images from the Gallery

I have spent days researching this issue and I am getting nowhere at all.  Things that have been accepted as correct by others are simply not working for me at all, and often the keywords they are using do not even exist. 
All I am trying to do is ask the user to select an image from the gallery.  I want to store this selection as a bitmap, convert the size of the image, and then save it to file. 
They have the option to do the same thing using the camera, and this code works perfectly.   Not sure why the gallery is so difficult.   Here is my code (starting with the line below that won't add to the code block for some reason):
if (requestCode == GALLERY_REQUEST && resultCode == RESULT_OK && null ! = data) {

            final Context context=this;
            Intent j=new Intent(context,PlayerSelection.class);
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent. ACTION_GET_CONTENT);
            Uri selectedImageUri = data.getData();
            String selectedImage = selectedImageUri.getPath();
            Toast.makeText(getApplicationContext(), selectedImage, Toast. LENGTH_LONG).show();
            String fName = new File(getFilesDir(), selectedImage).getAbsolutePath();
            fName = fName + ".jpg";
            Toast.makeText(getApplicationContext(), fName, Toast. LENGTH_LONG).show();
            try {
               Bitmap galleryTemp = MediaStore. Images. Media.getBitmap(this.getContentResolver(),selectedImageUri);
            } catch (IOException e) {
               e.printStackTrace();
            }
            //Bitmap galleryPic = Bitmap.createScaledBitmap(galleryTemp, 50, 50, false);
            //saveImageFile(galleryTemp);
            //startActivity(j);
        }

The sections that I have commented out above are where the app fails.  When I get the path for the file, I am directed to data\data\app.name\files\external\images\media\18630,
 but the actual file exists in **Phone\DCIM\Camera**
I think this is where the issue lies, as when I then try to manipulate, or do anything at all with the image (Bitmap galleryTemp), the app crashes. 
This is the method I use to call the above process:
case R.id.btnGallery:
            Intent i = new Intent(Intent. ACTION_PICK, MediaStore. Images. Media. INTERNAL_CONTENT_URI);
            startActivityForResult(i, GALLERY_REQUEST);
            break;

Any ideas?   I have read practically everything that exists on this subject and nothing is working for me. 

A:

Code failed due to a permissions issue.  For anyone else having this same problem, try adding this permissions line into your manifest.xml file:
<xml version="1.0" encoding="utf-8"? >
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.appname" >

<uses-permission android:name="android.permission. READ_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:name=". Globals"
    android:theme="@style/AppTheme" >

