Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying raw file into SDCard?

Tags:

I've some audio files in my res/raw folder. For some reasons, i want to copy this files to my SDCard When, my application starts.

How can i done this? Anyone guide me?

like image 315
Praveenkumar Avatar asked Dec 29 '11 05:12

Praveenkumar


1 Answers

Read from the resource, write to a file on the SD card:

InputStream in = getResources().openRawResource(R.raw.myresource); FileOutputStream out = new FileOutputStream(somePathOnSdCard); byte[] buff = new byte[1024]; int read = 0;  try {    while ((read = in.read(buff)) > 0) {       out.write(buff, 0, read);    } } finally {      in.close();      out.close(); } 
like image 141
Nikolay Elenkov Avatar answered Sep 24 '22 03:09

Nikolay Elenkov