1
I have an application that has a certain audio file, which is in /data/data/meu_pacote/audio_anexo/audio.mp3
, so far so good, the problem is that the Mediaplayer class of Android fails to run the file, and when I put the same file on memory card, it performs smoothly.
I believe I eat the briefcase /data/data/meu_pacote
belongs only to my application, Mediaplayer can not access the content that is inside it.
What is the solution?
Note: I have searched for Context.MODE_WORLD_READABLE
.
Below is the code to create the audio file, which I am using. There is some parameter that 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);
Take a look at Contentproviders, maybe to share the files using this feature: http://developer.android.com/guide/topics/providers/content-providers.html
– Wakim