2012-04-12 2 views
1

안녕하세요,안드로이드에 캐쉬하지 않는 우리 문자열

다음 코드를 사용 중입니다.

   String fileName = "image" + "_" + title.getText().toString()+"_" + val.toString(); 
       photo = this.createFile(fileName, ".jpg"); 
       intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); 
       uriOfPhoto = Uri.fromFile(photo); 
       startActivityForResult(intent, RESULT_CAMERA_SELECT); 
      } 
     } 
     catch(Exception e) 
     { 
      Log.v("Error", "Can't create file to take picture!"); 
      displayAlert("Can't create file to take picture!","SDCard Error!"); 
     } 
    } 

    private File createFile(String part, String ext) throws Exception 
    { 
     File tempDir = new File (Environment.getExternalStorageDirectory() + "/MyFolder/Images"); 
     if(!tempDir.exists()) 
     { 
      tempDir.mkdir(); 
     } 
     tempDir.canWrite(); 
     return new File(tempDir, part+ext); 
    } 
}); 

UriOfPhoto 나에게 디버그 chached하지 uriString을주고있다. 파일의 URI를 저장하지 않습니다. 어떻게하면이 문제를 해결할 수 있습니다.

authority Uri$Part$EmptyPart (id=830004244032) 
fragment Uri$Part$EmptyPart (id=830004245408) 
host "NOT CACHED" (id=830003914304) 
path Uri$PathPart (id=830067926736) 
port -2 
query Uri$Part$EmptyPart (id=830004245408) 
scheme "file" (id=830002660688)  
ssp null  
uriString "NOT CACHED" (id=830003914304) 
userInfo null  

안부

+0

캡처 한 이미지를 경로에 저장해야합니까? –

답변

0

이 충분한 정보가 아닙니다. 당신이 보낸 의도에 어떤 행동을 취하고 있습니까? createFile이 실제로 파일을 생성합니까?

제공하는 오류 목록은별로 유용하지 않습니다. 그것은 디버그에서 변수 값 목록의 일부입니까? 그렇다면 값을 볼 때 코드에서 어디에 있습니까?

+0

예, 새 파일을 만듭니다 .uriOfPhoto = Uri.fromFile (사진); 그 파일 사진의 uri 값을 얻고 싶습니다. 그러나 나는 위에옵니다. –

0
String fileName = Environment.getExternalStorageDirectory() + "/MyFolder/Images" + fileName + ".jpg"; 
UriOfPhoto = Uri.parse(fileName); 
Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.putExtra(MediaStore.EXTRA_OUTPUT, UriOfPhoto); 
startActivityForResult(intent, RESULT_CAMERA_SELECT); 

또한 방금 당신이하려고했던 같은 파일을 만들 사진이 안드로이드 OS 위와 같이해야합니다 URI를 전달해야 저장 사진의 파일을 만들 필요 없으며에서 캡처 한 이미지를 저장 저 사람.

관련 문제