1

I want to download a file and store it somewhere in my app, for example SharedPreferences, then I want to play it when a remote push notification is sent.

Is it possible? If so, where is the best place to store this audio file?

Erick Filho
  • 1,962
  • 3
  • 18
  • 31
  • http://stackoverflow.com/questions/13760168/how-to-set-notification-with-custom-sound-in-android – karan Dec 17 '15 at 12:38
  • http://stackoverflow.com/questions/12970748/how-to-set-notification-with-custom-sound – karan Dec 17 '15 at 12:38

1 Answers1

0

use raw/ folder

Arbitrary files to save in their raw form. To open these resources with a raw InputStream, call Resources.openRawResource() with the resource ID, which is R.raw.filename.

However, if you need access to original file names and file hierarchy, you might consider saving some resources in the assets/ directory (instead of res/raw/). Files in assets/ are not given a resource ID, so you can read them only using AssetManager.

And after Downloading use it like this

MediaPlayer mPlayer = MediaPlayer.create(context, R.raw.soundclip);
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mPlayer.start();
Keyur Lakhani
  • 4,321
  • 1
  • 24
  • 35