показать путь к изображению (выбранному из внутреннего хранилища для отображения в изображении) в текстовом представлении

Я показываю два изображения на двух изображениях, одно с кодом запроса 101, а другое с кодом 102.

startActivityForResult(Intent.createChooser(intent, "Select Picture"), 101);// change request
    startActivityForResult(Intent.createChooser(intent1, "Select Picture"), 102); // change request code

и я хочу, чтобы их имя пути, например, img1.jpg или путь, например, storage/emulated/0/DCIM/camera/img1.jpg отображались на 2 текстовых представлениях, которые у меня есть для этого, я пишу следующий код, но это сила остановка приложения

if (requestCode == 101) {
        Uri selectedImageUri = data.getData();
        ImageView iv = (ImageView) findViewById(R.id.imgView);
        File file = new File( getPathFromURI(selectedImageUri));
        String path = file.getAbsolutePath();
        iv.setImageBitmap(BitmapFactory.decodeFile(path));
        iv.setTag(path);
        String impath = (String) iv.getTag();
        TextView myText = (TextView) findViewById(R.id.tv);
        myText.setText(impath);
    }
    else if(requestCode == 102){
        Uri selectedImageUri = data.getData();
        ImageView iv = (ImageView) findViewById(R.id.imgView2);
        File file = new File( getPathFromURI(selectedImageUri));
        String path1 = file.getAbsolutePath();
        iv.setImageBitmap(BitmapFactory.decodeFile(path1));
        iv.setTag(path1);
        String impath = (String) iv.getTag();
        TextView myText1 = (TextView) findViewById(R.id.tv1);
        myText1.setText(impath);
    }
public String getPathFromURI(Uri contentUri) {
    String res = null;
    String[] proj = {MediaStore.Images.Media.DATA};
    Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
    if (cursor.moveToFirst()) {
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        res = cursor.getString(column_index);
    }
    cursor.close();
    return res;
}

Журнал ошибок говорит,

Process: select_image_demo.coderzheaven.com.selectimage, PID: 11845
              java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=102, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:42038 flg=0x1 }} to activity {select_image_demo.coderzheaven.com.selectimage/select_image_demo.coderzheaven.com.selectimage.MainActivity}: java.lang.NullPointerException
                  at android.app.ActivityThread.deliverResults(ActivityThread.java:4090)
                  at android.app.ActivityThread.handleSendResult(ActivityThread.java:4133)
                  at android.app.ActivityThread.-wrap20(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:154)
                  at android.app.ActivityThread.main(ActivityThread.java:6121)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
               Caused by: java.lang.NullPointerException
                  at java.io.File.<init>(File.java:262)
                  at select_image_demo.coderzheaven.com.selectimage.MainActivity.onActivityResult(MainActivity.java:84)
                  at android.app.Activity.dispatchActivityResult(Activity.java:6979)
                  at android.app.ActivityThread.deliverResults(ActivityThread.java:4086)
                  at android.app.ActivityThread.handleSendResult(ActivityThread.java:4133) 
                  at android.app.ActivityThread.-wrap20(ActivityThread.java) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1534) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:154) 
                  at android.app.ActivityThread.main(ActivityThread.java:6121) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 

person Community    schedule 28.01.2018    source источник
comment
Можете ли вы распечатать журнал ошибок.   -  person sandeep kolhal    schedule 28.01.2018
comment
Вы спрашиваете разрешения или нет?   -  person Aditya    schedule 28.01.2018
comment
Heisen-berg Я могу успешно отображать выбранные изображения в режиме просмотра изображений. это путь, с которым у меня проблемы   -  person    schedule 28.01.2018
comment
Я думаю, что ошибка в этой строке TextView myText1 = (TextView) findViewById(R.id.tv1); myText1.setText(импат);   -  person sandeep kolhal    schedule 28.01.2018