I want Android to play a song in /data/data/com.example.myapp/ called test3.mid
Do I need to put it in a subdirectory? Or am I calling setDataSource in a wrong way? The app crashes and gives me a NullPointerException.
try {
mediaPlayer.setDataSource("file://data/data/com.example.optimuse/test3");
} catch (Exception e1) {
e1.printStackTrace();
}
try {
mediaPlayer.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I got it. I put it in the cache folder and it works now. Plus, I stupidly forgot the new command (since create() didn’t seem to need it).
My working code:
I stored the file in the cache dir, that works!
And then calling the file: