Pregunta

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?

¿Fue útil?

Solución

 if(Intent.ACTION_VIEW.equals(action)){
 Uri uri = intent.getData();
 path = uri.getPath();
     path = path.replace("%20", " ");
 }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top