0

How to convert a URI in the form of

content://com.android.externalstorage.documents/document/primary%3Aresume.pdf 

to File in api 26. MyCode is

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case 200:
            if (resultCode == RESULT_OK) {
                // Get the Uri of the selected file
                Uri uri  = data.getData();
                File myFile = new File(uri.toString());
                if(!myFile.isFile()){
                    Toast.makeText(getApplicationContext(),"not a file",Toast.LENGTH_LONG).show();
                }
            }
            break;
    }
}

I always get "not a file" toast

Abhishek c
  • 539
  • 6
  • 16

0 Answers0