title: Media player not stopping old song when new song is selected. Throws a null pointer exception also
body: <p>Below code throws a null pointer exception at the "if" Condition.
  I have a list of songs and on click on an item I want that song to be played and while clicking next item the previous song should stop playing and the newly selected song should get played. Could someone please help me???</p>
  
  <pre><code>MediaPlayer player = null;
      public void ringtonelistview() {
          final CharSequence[] ringtoneList = { "city_nights.mp3",
                  "cute_morning_alarm.mp3", "melody_alarm_clock.mp3",
                  "morning_alarm.mp3", "powiadomienie.mp3", "silver.mp3" };
  
          AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
          alt_bld.setTitle("Select one Ringtone");
          alt_bld.setSingleChoiceItems(ringtoneList, -1,
                  new DialogInterface.OnClickListe`enter code here`ner() {
                      public void onClick(DialogInterface dialog, int item) {
                          final Uri myUri;
                          ringtoneName = (String) ringtoneList[item];
                          myUri = Uri.parse(getExternalFilesDir("").toString()
                                  + "/RINGTONEFOLDER/" + ringtoneName);
                          try {
                              if (null != player || player.isPlaying() == true) {
                                  player.stop();
                                  player.release();
                              } else {
                                  player = MediaPlayer.create(
                                          MainActivity.this,
                                          myUri);
                                  player.start();
                                  player = null;
                              }
                          } catch (Exception e) {
                              e.printStackTrace();
                          }
                      }
                  });
  </code></pre>