2011-09-23 4 views

답변

3
private void copytoSD() throws IOException{ 

      //Open your local file as the input stream 
      InputStream myInput = //your input Stream 

      // Path to the just created empty db 
      String outFileName = Environment.getExternalStorageDirectory().toString+"/filename.jpg"; 

      //Open the empty db as the output stream 
      OutputStream myOutput = new FileOutputStream(outFileName); 

      //transfer bytes from the inputfile to the outputfile 
      byte[] buffer = new byte[2048]; 
      int length; 
      while ((length = myInput.read(buffer))>0){ 
       myOutput.write(buffer, 0, length); 
      } 

      //Close the streams 
      myOutput.flush(); 
      myOutput.close(); 
      myInput.close(); 

     } 
관련 문제