Right place for putting mp3 files in an android project

The best place to put such .mp3 or any other files would be in the assets folder.

These files once stored will become a part of your android app itself and can be read easily. This tutorial describes it well.

 AssetFileDescriptor afd = getAssets().openFd("AudioFile.mp3");
 MediaPlayer player = new MediaPlayer();
 player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
 player.prepare();
 player.start();

Alternatively you can also store it in the raw folder and read it directly by specifying the path as the raw folder.
this can be played as:

int resID=getResources().getIdentifier(fname, "raw", getPackageName());
MediaPlayer mediaPlayer=MediaPlayer.create(this,resID);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)