2012-02-06 2 views
0

캔버스를 비트 맵으로 저장하려면이 코드를 작성했지만 작동하지 않습니다. 누구든지 도와 줄 수 있습니까?안드로이드가 내 파일을 만들 수 있음을 보장 할 수있는 방법

public void saveImage(){ 

    try { 

     Bitmap bitmap = object.getDrawingCache(); 
     path = Environment.getDataDirectory().getAbsolutePath(); 

     file = new File(path.toString() +"/image.png"); 
     FileOutputStream fos ; 

     fos = new FileOutputStream(file); 
     bitmap.compress(CompressFormat.PNG, 100, fos); 
     fos.flush(); 
     fos.close(); 
     isFileCreated = file.exists(); 

    } catch (FileNotFoundException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    }catch (IOException e){ 
     e.printStackTrace(); 
    } 

} 
+0

"작동하지 않았다"는 것은 무엇을 의미합니까? 보고 된 오류 또는 예외가 기록 되었습니까? –

답변

1

"작동하지 않음"이란 의미를 모르면 File을 다르게 작성하십시오. 이는 수동으로 경로를 작성하는 것보다 낫습니다.

file = new File(Environment.getDataDirectory(), "image.png"); 
관련 문제