title: Using shared preferences to store image URLs
body: <p>I am trying to figure out how I would achieve storing image URLs via onClick of an item button so they can be accessed by another class.</p>
  
  <p>I have looked around and saw that it would be best to achieve this using shared preferences.</p>
  
  <p>I have never used shared preferences before so I am a little confused as how I will be able to achieve this because I would like to get the URL from the String I have called "mImageUrl"</p>
  
  <p>I know my String "mImageUrl" will give me the URL of the image that is currently being viewed, so I like to somehow store the String/URL from my String to shared preferences so the specific URLs can used via another class.</p>
  
  <p>Would using shared prefs be a good way to achieve my requirement, 
  Any guidance would be appreciated thanks </p>
  
  <pre><code>    @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
      case R.id.SetWallpaper:
          new SetWallpaperAsync(getActivity()).execute(mImageUrl);
  
          break;
  
  
      case R.id.SaveWallpaper:
          new SaveWallpaperAsync(getActivity()).execute(mImageUrl);
  
          break;
  
      case R.id.FavouriteWallpaper:
          //Use shared preferences here somehow:
  
  
                  SharedPreferences preferences = this.getActivity().getSharedPreferences("pref",0);
  
          SharedPreferenceUtil.setSharedPreference(context, "ImageKey", mImageUrl);
  
          String url = SharedPreferenceUtil.getSharedPreference(context,"ImageKey",null);
  
          if(url != null){
             // set image source here..
          }
  
          break;
  
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>