I am trying to browse a file when a button is pressed and when the file is selected I print a toast of absolute path. Following is my code
 browse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                radioGroup.clearCheck();
                //Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                intent.setType("audio/*");
                startActivityForResult(intent,7);
            }
        });
And below is onActivityResult
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
super.onActivityResult(requestCode,resultCode,data);
        switch (requestCode) {
            case 7:
                if (resultCode == RESULT_OK) {
                    Uri uri = null ;
                    if (data !=null){
                        uri = data.getData(); //= data.getData();
                    try {
                        String mimeType = getContentResolver().getType(uri);
                        String path = cls2.getRealPath(this, uri);
                        Toast.makeText(MainActivity.this, (CharSequence) path, Toast.LENGTH_LONG).show();
             break;
                }catch(Exception e)
                {
                    Log.e("Exception found ",e.getMessage());
                }
            }
    }
    }
}
where cls2.getRealPath()
i.e.
RealPathUtil cls2 = new RealPathUtil();
getRealPath method and RealPathUtil class I got from following link
https://gist.github.com/tatocaster/32aad15f6e0c50311626
Above code is perfectly working in Android Lollipop, but when I run above code in Android Nougat , I don't get any path . What might the reason, does Nougat has got different API to access absolute path. And I have written the required permissions in the manifest file.