Example usage for android.content.res Resources openRawResourceFd

List of usage examples for android.content.res Resources openRawResourceFd

Introduction

In this page you can find the example usage for android.content.res Resources openRawResourceFd.

Prototype

public AssetFileDescriptor openRawResourceFd(@RawRes int id) throws NotFoundException 

Source Link

Document

Open a file descriptor for reading a raw resource.

Usage

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
    }
}