2012-07-23 5 views
1

친구 내 애플 리케이션을위한 PDF의 경로를 얻으려고 노력하고 있습니다. 안드로이드 전화에 n 개의 pdf가 있다고 가정하면 (루트 디렉토리 또는 sdcard에있을 수 있음) 어떻게하면 경로 을 프로그래밍 방식으로 얻을 수 있습니까? 어떤 사람이 나에게 몇 가지 힌트를 제안 해 주시겠습니까? 사전에안드로이드에서 pdf의 경로 얻기

감사

카란 SD 카드 확인을 위해

+1

이 링크를 참조하십시오. http://www.coderanch.com/t/533822/Android/Mobile/complete-path-file-android-application – rajeshwaran

답변

1
File images = Environment.getExternalStorageDirectory(); 
imagelist = images.listFiles(new FilenameFilter() 
{ 
public boolean accept(File dir, String name) 
{ 
return ((name.endsWith(".pdf"))); 
} 
}); 
pdflist = new String[imagelist.length]; 
for(int i = 0;i<imagelist.length;i++) 
{ 
pdflist[i] = imagelist[i].getName(); 
} 

이 링크를 참조 Assistance required for scanning the .mp3 files in sdcard

+0

내 전화에있는 모든 PDF 파일의 경로를 가져 오는 m 덕분에 톤 – karansingh1487

+0

이봐, 한 가지는 PDF를 스캔하는 것입니다. bt NT 모든 전화의 pdf는 ... 일부 pdf가 다른 폴더에서 dere이고 wht 인 경우? – karansingh1487

+0

전화의 경로를 사용하면 전화의 경로를 검색 한 다음 모든 작업이 코드에 의해 완료되고 google을 사용하여 전화의 경로를 얻습니다. – Nitin

0

if (android.os.Environment.getExternalStorageState().equals(
      android.os.Environment.MEDIA_MOUNTED)) { 
     File f = new File(Environment.getExternalStorageDirectory()); 

     File[] files = f.listFiles(); 
     File file; 
     for (int i = 0; i < files.length; i++) { 
       file = files[i]; 
     } 
    } 

    //For Internal Memory 

    else { 
      /* save the folder in internal memory of phone */ 

     File f = new File("/data/data/com.your.package/"); 
     File[] files = f.listFiles(); 
    }