有没有像RES /可绘制为MP3或一般的音频文件中的任何文件夹?如果是的话,它是什么,我怎么能得到它的访问从应用程序?
Is there any folder like res/drawable for mp3 or generally audio files? If yes, what is it and how can I get access to it from the app?
把最好的地方,例如 MP3播放
或任何其他文件将在资产
文件夹。
The best place to put such .mp3
or any other files would be in the assets
folder.
在存储将成为你的android应用程序本身的一部分,并可以很容易地读取这些文件。这教程 desscribes很好。
These files once stored will become a part of your android app itself and can be read easily. This tutorial desscribes it well.
AssetFileDescriptor afd = getAssets().openFd("AudioFile.mp3");
player = new MediaPlayer();
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
player.prepare();
player.start();
另外,您还可以将其存储在原
文件夹,并通过指定路径的原始文件夹diractly阅读。
这可能是播放器
Alternatively you can also store it in the raw
folder and read it diractly by specifying the path as the raw folder.
this can be player as
int resID=getResources().getIdentifier(fname, "raw", getPackageName());
MediaPlayer mediaPlayer=MediaPlayer.create(this,resID);