title: Cannot display the selected image from mobile storage (Android Studio)
body: <p>My code is working fine for selecting images from the phone, but I can't see a preview before uploading it, why? what's wrong?</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements View.OnClickListener{
  
  private static final int PIC_ID = 1;
  Button uButton, dButton;
  EditText firstText, secondText;
  ImageView firstImage, secondImage;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      uButton = (Button)findViewById(R.id.uButton);
      dButton = (Button)findViewById(R.id.dButton);
  
      firstText = (EditText)findViewById(R.id.firstText);
      secondText = (EditText)findViewById(R.id.secondText);
  
      firstImage = (ImageView)findViewById(R.id.firtsImage);
      secondImage = (ImageView)findViewById(R.id.secondImage);
  
      firstImage.setOnClickListener(this);
      uButton.setOnClickListener(this);
      dButton.setOnClickListener(this);
  
  }
  
  
  @Override
  public void onClick(View v) {
      switch(v.getId()){
          case R.id.firtsImage:
              Intent imageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
              startActivityForResult(imageIntent, PIC_ID);
              break;
          case R.id.dButton:
              break;
          case R.id.uButton:
              break;
      }
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if(requestCode == PIC_ID &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null){
         Uri selected = data.getData();
          firstImage.setImageURI(selected);
  
      }
  }
  </code></pre>
  
  <p>and my activity_main.xml file is</p>
  
  <pre><code>&lt;LinearLayout
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"&gt;
  
  
     &lt;ImageView
     android:id="@+id/firtsImage"
     android:layout_gravity="center_horizontal"
     android:layout_width="150dp"
     android:layout_height="150dp" /&gt;
  
  
     &lt;EditText
         android:id="@+id/firstText"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" /&gt;
  
  
     &lt;Button
         android:id="@+id/uButton"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="Upload"/&gt;
  
  
  
  
     &lt;ImageView
         android:id="@+id/secondImage"
         android:layout_gravity="center_horizontal"
         android:layout_width="150dp"
         android:layout_height="150dp" /&gt;
  
  
     &lt;EditText
         android:id="@+id/secondText"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" /&gt;
  
  
     &lt;Button
         android:id="@+id/dButton"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="download"/&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <p>I've googled it until I got a headache found nothing.</p>