i am creating an app i store a file in raw folder with name
alarm_tone.mp3
i am saving it in one
SharedPreferences shared=getSharedPreferences(PREFS_NAME,0);
SharedPreferences.Editor editor=shared.edit();
editor.putString("music_uri", "android.resource://" + "org.riteshmapsapplicationdemo/" + R.raw.alarm_tone);
editor.commit();
in other activity i am playing this tone using code segment
player=new MediaPlayer();
try {
player.setDataSource(pref.getString("music_uri", null));
player.prepare();
player.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
it is showing
Media.prepare() failed
java.io.IOException
You should parse Uri: