code: public void setSampleRate(final int sampleRateInHertz){
          if (sampleRateInHertz!=DEFAULT_AUDIO_SAMPLE_RATE_HERTZ && sampleRateInHertz !=22050
                  && sampleRateInHertz != 16000 && sampleRateInHertz !=11025){
              throw new IllegalArgumentException("Invalid sample rate given");
          }
          else if (currentAudioState.get()!=PREPARED_STATE && currentAudioState.get()!=INITIALIZED_STATE ){
              throw new IllegalStateException("Recorder cannot have its sample rate changed when it is not in an initialized or prepared state");
          }
          this.sampleRateInHertz=sampleRateInHertz;
      }
docs: Sets the sample rate for the recording.
  @param sampleRateInHertz The sample rate to record the audio with.
  @throws IllegalArgumentException If the sample rate is not: 44100,22050,16000, or 11025
  @throws IllegalStateException If the API is called while the recorder is not initialized or prepared.