I have an application that has a certain audio file, which is in /data/data/meu_pacote/audio_anexo/audio.mp3
, so that's fine, the problem is that the MediaPlayer class of Android can not execute the file, and when I put the same file on the memory card, it runs smoothly .
I believe that since the /data/data/meu_pacote
folder only belongs to my application, MediaPlayer can not access content that is inside it.
What is the solution?
Note: I already searched for Context.MODE_WORLD_READABLE
.
Below is the code for creating the audio file, which I am using. Is there any parameter I need to pass?
File diraudio = new File("/data/data/br.meupacote.meuapp/audio_anexo/");
//Verifica se o diretorio nao existe e cria ele;
if(!diraudio.exists())
{
Log.i("XDEBUG","Pasta para áudio foi criada!");
diraudio.mkdir();
}
String caminho = dir + audiofile.getName();
InputStream in = new FileInputStream(audiofile);
byte[] b = IOUtils.toBytes(in);
File file = new File(caminho);
@SuppressWarnings("resource")
FileOutputStream fos = new FileOutputStream(file);
fos.write(b);