2012-02-10 2 views
2

나는 SD 카드에 저장하려는 비트 맵을 가지고 있습니다. 저장된 파일 android는 비트 맵에 이름을 지정하고 저장합니다

  • 파일을 저장
  • 내가 스택 오버플로 둘러 보았다 두 문제에 대한 일을 아무것도, (찾을 수 없습니다에

    1. 설정 이름 : 그 2 문제가 대부분 저장 부분을 위해, 세트 이름 부분은 나를 혼란스럽게 만들었습니다.)

      간단한 간단한 해결책이 있습니까?

      감사합니다.

    답변

    2
    Bitmap yourBitmap; // you have to get your bitmap into this variable 
    String filePath = "/mnt/sdcard/"; // some times it may be only /sdcard not /mnt/sdcard 
    filePath += "newFileName.jpg"; 
    
         try { 
          yourBitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File(filePath))); 
         } catch (FileNotFoundException e) { 
          // TODO Auto-generated catch block 
          e.printStackTrace(); 
         } 
    

    매니페스트 파일에 허가 아래 사용해야합니다.

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    
    +0

    어디에서 manufest에 대한 권한을 추가합니까? –

    +0

    전에 또는 이후

    +0

    nevermind, 그것을 발견 –

    0

    이 시도 :

    FileOutputStream out = new FileOutputStream(new File("/mnt/sdcard/pic.jpg")); 
    yourBitmap.compress(Bitmap.CompressFormat.JPG, 80, out); 
    out.close(); 
    
    관련 문제