2013-06-07 2 views
0

비트 맵 이미지를 Android 내부 저장 공간에 저장했습니다. 이제 /myphoto.jpg라는 이미지를 검색하고 shareIntent를 사용하여 공유하고 싶습니다. 내부 저장 메모리에서 myphoto.jpg를 어떻게 읽을 수 있습니까? 이상적으로 나는 파일 경로를 얻을 것으로 예상한다.Android 내부 저장 메모리에서 Jpeg 읽기

ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream(); 
    bm.compress(Bitmap.CompressFormat.JPEG, 100, outputBuffer); 
    byte[] byteImage1=outputBuffer.toByteArray(); 


    //save file to internal storage 
    FileOutputStream outputStream; 

    try { 
     outputStream = context.openFileOutput("myphoto.jpg", Context.MODE_PRIVATE); 
     outputStream.write(byteImage1); 
     outputStream.close(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
+0

이미지를 저장하는 코드를 인쇄합니다. – IronBlossom

답변

1

당신은 코드 아래 사용하여 sdcard에 모든 이미지를 얻을 수 있습니다 :

FileFilter filterForImageFolders = new FileFilter() 
    {    
     public boolean accept(File folder) 
     { 
      try 
      { 
       //Checking only directories, since we are checking for files within 
       //a directory 
       if(folder.isDirectory()) 
       { 
        File[] listOfFiles = folder.listFiles(); 

        if (listOfFiles == null) return false; 

        //For each file in the directory... 
        for (File file : listOfFiles) 
        {        
         //Check if the extension is one of the supported filetypes       
         //imageExtensions is a String[] containing image filetypes (e.g. "png") 
         for (String ext : imageExtensions) 
         { 
          if (file.getName().endsWith("." + ext)) return true; 
         } 
        }       
       } 
       return false; 
      } 
      catch (SecurityException e) 
      { 
       Log.v("debug", "Access Denied"); 
       return false; 
      } 
     } 
    }; 

지금과 같이이 방법을 사용 :

File extStore = Environment.getExternalStorageDirectory(); 
File[] imageDirs = extStore.listFiles(filterForImageFolders); 
+0

이 작동했는지 여부. ?? – Riser

관련 문제