List of usage examples for android.content.res Resources openRawResourceFd
public AssetFileDescriptor openRawResourceFd(@RawRes int id) throws NotFoundException
From source file:it.interfree.leonardoce.bootreceiver.AlarmKlaxon.java
private void setDataSourceFromResource(Resources resources, MediaPlayer player, int res) throws java.io.IOException { AssetFileDescriptor afd = resources.openRawResourceFd(res); if (afd != null) { player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); afd.close();//from w w w . j a v a 2 s . c om } }