title: Preference Dialog: NumberPicker ClassCast Exception
body: <p>just trying to get a NumberPicker run in my preference.. looked at code here, but always get an <strong>java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer</strong> on <strong>this.persistInt(time)</strong>..</p>
  
  <p>Thank's a lot!</p>
  
  <pre><code>import android.content.Context;
  import android.preference.DialogPreference;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.NumberPicker;
  
  public class NumberPickerPreference extends DialogPreference {
  
  
      private int number = 0;
      private NumberPicker picker = null;;
  
      public NumberPickerPreference(final Context context,
              final AttributeSet attrs) {
          super(context, attrs);
  
          this.setPositiveButtonText("Set");
          this.setNegativeButtonText("Cancel");
      }
  
      @Override
      protected View onCreateDialogView() {
          this.picker = new NumberPicker(this.getContext());
          return (this.picker);
      }
  
      @Override
      protected void onBindDialogView(final View view) {
          super.onBindDialogView(view);
  
          this.picker.setMinValue(1);
          this.picker.setMaxValue(100);
  
      }
  
      @Override
      protected void onDialogClosed(final boolean positiveResult) {
          super.onDialogClosed(positiveResult);
  
          if (positiveResult) {
  
              this.number = this.picker.getValue();
  
              final int time = Integer.valueOf(this.number);
  
              if (this.callChangeListener(time)) {
                  this.persistInt(time);
              }
          }
      }
  }
  </code></pre>