android - Write .3gp file on sd card -


i have .3gp audio file stored in sd card.i want copy file folder of sd card.i have googled lot didn't working idea.please me if knows.the code have tried till given below:

private void save(file file_save) {      string file_path = environment.getexternalstoragedirectory()             .getabsolutepath() + "/recordedaudio";     file file_dir = new file(file_path);     if (file_dir.exists()) {         file_dir.delete();     }     file_dir.mkdirs();     file file_audio = new file(file_dir, "audio"             + system.currenttimemillis() + ".3gp");     try {          bytearrayoutputstream bos = new bytearrayoutputstream();         objectoutput out = new objectoutputstream(bos);         out.writeobject(file_save);         out.close();         fileoutputstream fos = new fileoutputstream(file_audio);          byte[] buffer = bos.tobytearray();         fos.write(buffer);          fos.flush();         fos.close();      } catch (filenotfoundexception e) {         // todo auto-generated catch block         e.printstacktrace();     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     }  } 

this create new file size of 100.thanks in advance... code when call save() method is:

 mfilefirst = new file(mfilename);//mfilename path of sd card .3gp file located     save(mfilefirst); 

try this

private void save(file file_save) {     string file_path = environment.getexternalstoragedirectory()             .getabsolutepath() + "/recordedaudio";     file file_dir = new file(file_path);     if (file_dir.exists()) {         file_dir.delete();     }     file_dir.mkdirs();     file file_audio = new file(file_dir, "audio"             + system.currenttimemillis() + ".3gp");     try {          fileinputstream fis = new fileinputstream(file_save);         fileoutputstream fos = new fileoutputstream(file_audio);          byte[] buf = new byte[1024];         int len;         int total = 0;         while ((len = fis.read(buf)) > 0) {             total += len;             fos.write(buf, 0, len);             // flush stream once every             if (total > (20 * 1024)) {                 fos.flush();             }         }         fos.flush();         fis.close();         fos.close();      } catch (filenotfoundexception e) {         e.printstacktrace();     } catch (ioexception e) {         e.printstacktrace();     }  } 

Comments