for loading image from gallery you can use it and you have the create provide in manifest
<provider
   android:name="android.support.v4.content.FileProvider"
   android:authorities="com.example.android.fileprovider"
   android:exported="false"
   android:grantUriPermissions="true">
   <meta-data
       android:name="android.support.FILE_PROVIDER_PATHS"
       android:resource="@xml/provider_paths"></meta-data>
</provider>
create your @xml/provide_paths like this
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="my_images" 
path="Android/data/package_name/files/Pictures" /> //pictures is the folder where your image will store
</paths>
code:
if (resultCode == Activity.RESULT_OK) { //onActivity you will get the result like this way
                    if (data != null) {
                        Uri contentURI = data.getData();
                        String path = null;
                        try {
                            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),contentURI);
                            path = saveImage(bitmap);
                         //   decodeImage(path);
                            img.setImageBitmap(bitmap);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        mCurrentPhotoPath = path;
                    }
                }
public void activeGallery() {// for taking the picture from gallery
        Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(galleryIntent,RESULT_LOAD_IMAGE);
    }
and for capture image in on Activity use
 Bundle bundle=data.getExtras();  // 
                        Bitmap bitmap= (Bitmap) bundle.get("data");
                        img.setImageBitmap(bitmap);
                        saveImage(bitmap);
 public String saveImage(Bitmap myBitmap) { //this method will compress your image
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        myBitmap.compress(JPEG, 90, bytes);
        File wallpaperDirectory = new File(Environment.getExternalStorageDirectory() , ""+IMAGE_DIRECTORY);
        // have the object build the directory structure, if needed.
        if (!wallpaperDirectory.exists()) {
            wallpaperDirectory.mkdirs();
        }
        try {
            File f = new File(wallpaperDirectory, Calendar.getInstance()
                    .getTimeInMillis() + ".jpg");
            f.createNewFile();
            FileOutputStream fo = new FileOutputStream(f);
      //      FileOutputStream fos = new FileOutputStream(f);
            myBitmap.compress(JPEG, 90, fo);
            fo.write(bytes.toByteArray());
            MediaScannerConnection.scanFile(this,
                    new String[]{f.getPath()},
                    new String[]{"image/jpeg"}, null);
            fo.close();
            Log.d("TAG", "File Saved::--->" + f.getAbsolutePath());
            return f.getAbsolutePath();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        return "";
    } 
 public void activeTakePhoto() {// it will go on camera intent
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // Ensure that there's a camera activity to handle the intent
        if (takePictureIntent.resolveActivity(getApplicationContext().getPackageManager()) != null) {
            // Create the File where the photo should go
            File photoFile = null;
            try {
                photoFile = createImageFile();
            } catch (IOException ex) {
                // Error occurred while creating the File
            }
            // Continue only if the File was successfully created
            if (photoFile != null) {
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                        Uri.fromFile(photoFile));
                startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
            }
        }
    }