title: Random sound from my own DB
body: <p>i create a DB sqlite with DB browser.
  I need to start an randomized audio from my Db.
  The table is "audio" with 4 field (Id, audio , col2, col3)
  I put in "audio" field the R.raw.nameaudio.</p>
  
  <p>this is the random number: </p>
  
  <pre><code>       rand = new Random();
         int random=rand.nextInt(4)+1;
  </code></pre>
  
  <p>this is the query:</p>
  
  <pre><code>    public Cursor cont(Integer ID){
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor res = db.rawQuery("select audio from audio where ID= "+ID, null);
      return res; }
  </code></pre>
  
  <p>Now i need to start MediaPlayer but it does not work.</p>
  
  <p>this is the rest of the code:</p>
  
  <pre><code>       Cursor res = mDBHelper.controllo(random);
                      while (res.moveToNext()) {
                          int audio = res.getInt(0);
                          stopPlaying();
              mp = MediaPlayer.create(getApplicationContext(),audio);
                          mp.start();
  
                      }
  </code></pre>
  
  <p>There is a problem with second argument of mediaplayer.create.
  I cant pass the right data type. How i can fix this?</p>
  
  <p>Thank you so much.</p>
  
  <p>EDIT:
  i try to put only "nameaudio" in the field "audio". After i insert:</p>
  
  <pre><code>                int audio = getResources().getIdentifier(res.getString(0), 
                                                     "raw", "mypackage");
                                                   stopPlaying();
  
                    mp = MediaPlayer.create(getApplicationContext(),audio);
                          mp.start();
  </code></pre>
  
  <p>Now i listn the audio but after some click the app crash.</p>