0

I have the problem geting Uri.getPath() includes /-1/1/ as below, The Uri was getting inside

protected void onActivityResult(int reqCode, int resultCode, Intent data)

from PICK Multiple Images as following

 ClipData.Item item = clipData.getItemAt(i);
 Uri uri = item.getUri();

I have try to get File from Uri, the following sample codes always getting error : FileNotFound

private void getImg(Uri uri){
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(new File(uri.getPath()).getAbsolutePath(), options);
    int imageHeight = options.outHeight;
    int imageWidth = options.outWidth;
    /....... some code ...

    // ArrayList<File> 
    mFile.add(new File(uri.getPath()); 
}



06-29 12:33:34.829 8160-8160/com.jinn.mutita.photoImx E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: 
/-1/1/content:/media/external/images/media/15878/ORIGINAL/NONE/3385104: open failed: ENOENT (No such file or directory)

However if I get as the following and save to local file: it can be done.

InputStream input = thiscontext.getContentResolver().openInputStream(uri);

But I can do to safe input stream locally first, please help, I have searching already but Not sure that the Uri format have been changed or now.

How to handle File with Path from Uri? . Thanks

mutita k
  • 11
  • 2

1 Answers1

1

I just found this and it solve the problems, because of Permission

Android strorage access framework persistable permission not granted during asyntask

mutita k
  • 11
  • 2