title: setImageUri() is not showing image after getting Uri string from SharedPreferences using Gson
body: <p>I have <code>ArrayList</code> of a custom object that is image object that will store the image Uri in form of a string. When I display image by using <code>setImageUri()</code> from ArrayList Uri it is displaying the image correctly but after saving <code>ArrayList</code> to <code>SharedPreferences</code> by using <code>Gson</code> and when I get back this ArrayList from SharedPreferences in <code>onCreate()</code> it is not displaying image in imageview.
  I debug my code it gets the Uri properly from SharedPreferences but why it is not displaying image.</p>
  
  <p>This is my <strong>GridViewActivity</strong> code:</p>
  
  <pre><code>public class GridViewActivity extends AppCompatActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_grid_view);
          recyclerView=findViewById(R.id.recycler_view);
          recyclerView.setHasFixedSize(true);
          autoFitGridLayoutManager=new AutoFitGridLayoutManager(context,250);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          recyclerView.setLayoutManager(autoFitGridLayoutManager);
          arrayList=new ArrayList&lt;&gt;();
          sharedPref=new SharedPref(context);
          if (sharedPref.getCount()==0) {
              Toast.makeText(context, "No images...", Toast.LENGTH_SHORT).show();
          }
          else {
              Gson gson=new Gson();
              String response=sharedPref.getImages();
              arrayList=gson.fromJson(response,new TypeToken&lt;ArrayList&lt;Images&gt;&gt;(){}.getType()); //getting arraylist back
              Log.d("ROHIT", String.valueOf(arrayList.size())); //it displays the arraylist size correctly
              Images images=arrayList.get(0);
              Log.d("ROHIT","aya: "+images.getImage()); //Uri is also correct
  
              Intent intent=new Intent(context,Temp.class);
              intent.putExtra("image",images.getImage()); //passing it to the Temp activity
              startActivity(intent);
          }
      }
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          if(item.getItemId()==R.id.add_imges_cam) {
              //open camera
          }
          else if(item.getItemId()==R.id.add_imges_gallery) {
              //open gallery to select images
              Intent intent = new Intent();
              intent.setType("image/*");
              intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
              intent.setAction(Intent.ACTION_GET_CONTENT);
              startActivityForResult(Intent.createChooser(intent,"Select Picture"), PICK_IMAGE_MULTIPLE);
          }
          return super.onOptionsItemSelected(item);
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          int count=0;
          if(requestCode==PICK_IMAGE_MULTIPLE &amp;&amp; resultCode==RESULT_OK) {
              String[] filePath = {MediaStore.Images.Media.DATA};
  
              if (data.getData() != null) {
                  //if single image is selected
                  Uri imageUri = data.getData();
                  Cursor cursor = getContentResolver().query(imageUri, filePath, null, null, null);
                  cursor.moveToFirst();
                  arrayList.add(new Images(imageUri.toString()));
                  cursor.close();
              } else {
                  if (data.getClipData() != null) {
                      ClipData mClipData = data.getClipData();
                      for (int i = 0; i &lt; mClipData.getItemCount(); i++) {
                          ClipData.Item item = mClipData.getItemAt(i);
                          Uri uri = item.getUri();
                          // Get the cursor
                          Cursor cursor = getContentResolver().query(uri, filePath, null, null, null);
                          // Move to first row
                          cursor.moveToFirst();
                          arrayList.add(new Images(uri.toString()));
                          count++;
                          cursor.close();
                      }
                  }
              }
              imagesAdapter=new ImagesAdapter(context,arrayList);
              Images images=arrayList.get(0);
  
              Intent intent=new Intent(context,Temp.class); //when i called Temp activity before saving arraylist to sharedPref it displays image correctly in Temp activity
              intent.putExtra("image",images.getImage());
              startActivity(intent);
  
              sharedPref.save(arrayList); //saving arraylist to sharedPref
              sharedPref.updateCount(count);
              setRecyclerView();
          }
      }
  
  }
  </code></pre>
  
  <p>This is my <strong>SharedPref</strong> code</p>
  
  <pre><code>public class SharedPref {
      SharedPreferences sharedPreferences;
      SharedPreferences.Editor editor;
      Context context;
  
      public SharedPref(Context context) {
          this.context=context;
          sharedPreferences=context.getSharedPreferences("Grid_images",Context.MODE_PRIVATE);
          editor=sharedPreferences.edit();
      }
  
      public void save(ArrayList&lt;Images&gt; arrayList) {
          Gson gson=new Gson();
          Object src;
          String json=gson.toJson(arrayList);
          editor.putString("grid_images",json);
          editor.apply();
          editor.commit();
      }
  
      public void updateCount(int i) {
          editor.putInt("images_count",i);
          editor.apply();
          editor.commit();
      }
  
      public int getCount() {
          return sharedPreferences.getInt("images_count",0);
      }
  
      public String getImages() {
          return sharedPreferences.getString("grid_images",null);
      }
  
      public void clearData() {
          editor.clear();
          editor.commit();
      }
  }
  </code></pre>
  
  <p>This is Temp.class code</p>
  
  <pre><code>public class Temp extends AppCompatActivity {
      ImageView imageView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_temp);
          imageView=findViewById(R.id.im_temp);
          Log.d("ROHIT","inside tmep: "+getIntent().getStringExtra("image"));
          imageView.setImageURI(Uri.parse(getIntent().getStringExtra("image")));
      }
  }
  </code></pre>