2013-04-20 2 views
3

안드로이드 및 저장소 옵션 (내부 저장소)에 문제가 있습니다.내 리소스 파일은 어디에 있습니까

"원시"디렉토리에 SSL 인증서를 추가 했으므로 저장소에 쓰기를 원합니다. 순간에서

이 코드 조각으로 노력하고있어 :

  InputStream is = SA.getResources().openRawResource(R.raw.myResource); 
      ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 

      int nRead; 
      byte[] data = new byte[16384]; 

      while ((nRead = is.read(data, 0, data.length)) != -1) 
      { 
      buffer.write(data, 0, nRead); 
      } 

      buffer.flush(); 

      FileOutputStream fos = SA.openFileOutput("Resource.crt", 0); 
      fos.write(buffer.toByteArray()); 
      fos.close(); 
      is.close(); 
      buffer.close(); 
      File f = new File(this.fileList()[0]); 
      if(f.exists()) 
      { 
       Log.v("File:", "Found"); 
      } 
      else 
      { 
       Log.v("File:", "Not found"); 
      } 

내 파일을 찾을 수 없습니다. 나는 이유를 모른다.

+0

포스트의 fileList() 메소드의 코드를? 문제의 코드가 활동 또는 수업에 있었던 곳은 어디입니까? 더 많은 정보가 필요합니다. –

+0

여기 FileList : http://developer.android.com/reference/android/content/Context.html#fileList() – GoatMachine

+0

인증서 파일의 이름을 완전히 소문자로 지정하십시오. 실제로 'myResource'라고 불리는 경우 소문자, 숫자, 밑줄 및 전체 정지 만 허용되므로 앱에 컴파일되지 않을 수 있습니다. –

답변

관련 문제