Question

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?

Was it helpful?

Solution

 if(Intent.ACTION_VIEW.equals(action)){
 Uri uri = intent.getData();
 path = uri.getPath();
     path = path.replace("%20", " ");
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top