title: How to save and fetch integer value in Shared Preference in android?
body: <blockquote>
    <p>I want to save and fetch the static integer value of Snow Density in Shared Preferences and change when user select another value in the Single choice.<br>
     My Code :</p>
  </blockquote>
  
  <pre><code>public static int mSnowDensity;
  AlertDialog.Builder mABuilder = new AlertDialog.Builder(AAA.this);
  final CharSequence mCharSequence[] = { "Low", "Medium", "High" };
  mABuilder.setTitle("Set Density of Snow");
  mABuilder.setSingleChoiceItems(mCharSequence,
          WallpaperServices.mDensitySnow,
          new android.content.DialogInterface.OnClickListener() {
  
              public void onClick(DialogInterface dialog, int which) {
                  if (which == 2) {
  
                      mSnowDensity = 90;
               /*I Want to save mSnowDensity Value In Shared Preferences */
                  } else if (which == 1) {
  
                       mSnowDensity = 60;
                  } else {
  
                       mSnowDensity = 30;
                  }
  
                  dialog.dismiss();
              }
          });
  </code></pre>