마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

외부저장소로 파일복사 질문

0 추천
public void copyFile(String copyPath,String pastePath){
String abPath=Environment.getExternalStorageDirectory().getPath();
File copyFile=new File(copyPath);
File pasteFile=new File(pastePath);
String fileName=new File(pastePath).getName();

FileInputStream inputStream=null;
try{
 inputStream=new FileInputStream(copyFile);
}catch(FileNotFoundException e){
 e.printStackTrace();
}
FileOutputStream outputStream=null;
try{
 outputStream=new FileOutputStream(pasteFile);
 }catch(FileNotFoundException e){
  e.printStackTrace();
 }
 FileChannel fcin=inputStream.getChannel();
 FileChannel fcout=outputStream.getChannel();
 long size = 0;
                try {
                    size = fcin.size();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                try {
                    fcin.transferTo(0, size, fcout);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                try {
                    fcout.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                try {
                    fcin.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                try {
                    outputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
}

위에 코드대로 제가 copyPath를 입력하면 pastePath에 복사가 되도록 짜봤는데요

제 폰으로 실험한결과 내부에서 내부로, 외장sd에서 내부로 usb에서 내부로는 복사가됩니다

근데 왜 내부에서 외장sd나 usb로 복사가안될까요...?ㅠㅠ

도와주십쇼!!!고수님들
JesusLovesYou (2,700 포인트) 님이 2016년 1월 15일 질문

1개의 답변

+1 추천
 
채택된 답변
저도 자세하게 아는것은 아니지만 권한 문제가 아닐까 생각을 해보았습니다. 이게 맞을 지는 모르겠지만 관련 링크 달께여

http://ismydream.tistory.com/124
hhjung1202 (1,280 포인트) 님이 2016년 1월 16일 답변
JesusLovesYou님이 2016년 1월 18일 채택됨
...