Reputation: 1765
I get my raw resource:
InputStream myRawResource = context.getActivity().getResources().openRawResource(myID);
How can I write this to a file? An MP3 file on the device.
Upvotes: 2
Views: 584
Reputation: 109237
try
{
File f=new File("myFile.mp3");
InputStream myRawResource = context.getActivity().getResources().openRawResource(myID);
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();
System.out.println("\nFile is created........
...........................");
}
catch (IOException e){}
}
Upvotes: 1