title: Saving an image to imageview picked from gallery in API 30
body: <p>this is the code i'm using for picking an image form gallery and use it for profile picture on the app. it works fine with all the versions below API 30. how can i make it work in all versions of AI can anybody help?</p>
  <pre><code>        profilresmi.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT );
              intent.setType(&quot;image/*&quot;);
              startActivityForResult(intent,CHOOSE_IMAGE);
  
          }
      });
  
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
  
      if (requestCode == CHOOSE_IMAGE &amp;&amp; resultCode == RESULT_OK) {
          imageUri = data.getData();
          profilresmi.setImageURI(imageUri);
  
  
          SharedPreferences sp = getSharedPreferences(&quot;profil&quot;, MODE_PRIVATE);
          SharedPreferences.Editor editor = sp.edit();
  
          editor.putString(&quot;imageuri&quot;, imageUri.toString());
          editor.commit();
  
  
      }
  }
  
  
  
  private  void setimage(){
      SharedPreferences sh = getSharedPreferences(&quot;profil&quot;,MODE_APPEND);
      String imageUriString = sh.getString(&quot;imageuri&quot;, &quot;&quot;);
  
  
      Uri imageUri = Uri.parse(imageUriString);
      if(imageUri.toString().length() == 0){
  
      }else {
          profilresmi.setImageURI(imageUri);
      }
  </code></pre>