문제

My app intends to launch a file using ACTION_VIEW. The following code returns the file path of the selected file

 if(Intent.ACTION_VIEW.equals(action)){
String Path = intent.getDataString();
    //file processing code
    }

It works fine when the selected file has no spaces in it. e.g Path becomes "/mnt/sdcard/sample.pdf" , but when i select a file with spaces in it's name such as "/mnt/sdcard/4C 1099 + 2 WOOO6.pdf" Path becomes "/mnt/sdcard/4C%20%20%201099%20%20%20%2B%20%202%20W0006.pdf"

Any help?

도움이 되었습니까?

해결책

 if(Intent.ACTION_VIEW.equals(action)){
 Uri uri = intent.getData();
 path = uri.getPath();
     path = path.replace("%20", " ");
 }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top