Im getting an input stream, which is an mp3 in my raw folder, and then I am trying to write it back to the raw folder (I know this sounds stupid but I want to do it), but I get an error – file not found, myFile.mp3. Any ideas where I am going wrong?
try
{
File f=new File("android.resource//com.apps/raw/myFile.mp3");
InputStream myRawResource = context.getActivity().getResources().openRawResource(mp3ID);
OutputStream out=new FileOutputStream(f);
byte buf[]=new byte[1024];
int len;
while((len=myRawResource.read(buf))>0)
out.write(buf,0,len);
out.close();
myRawResource.close();
}
catch (IOException e){
//error
}
This can’t be done because resources, at runtime, are read-only, are stored in the APK, and would need to be compiled for inclusion in R at compile time.