OpenURL : open local file containing a space (Android)
Hello everyone,
I have tried unsuccessfully to open a .pdf file that contains a space, in the default PDF player, from my Android tablet.
I use the following call:
Application.OpenURL (Application.PersistentDataPath + "/My file.pdf");
or in other words :
Application.OpenURL ( "/storage/emulated/0/Android/data/com.blabla.blibli/files/My file.pdf" );
Nothing is happening.
If I use another .pdf file without space (MySecondFile.pdf), it works perfectly. On Windows and Editor it works nice too.
So I tried to replace the space with %20. In this case the pdf application starts but replies that it can't load the file.
I have also tried using "file://" in front of the path and/or with WWW.EscapeURL applied on the filename ... but nothing works.
Can someone help me?
Thank you in advance.
Answer by Phanou · Oct 31, 2018 at 02:08 PM
i have the same problem. I can't open local file but also without space. Application.OpenURL( ) do noting in Android device (7.0) for local file (ok for open internet url). All work fine in windows. Is there some option compilation need ?
My code is : string pathFile = Path.Combine(Application.persistentDataPath,"test.pdf");
if (File.Exists(pathFile))
{
try
{
Application.OpenURL(pathFile);
Debug.Log("File exist : " + pathFile);
}
catch (IOException e)
{
Debug.Log("Error at ImagePicklerScript :\n" + e.ToString());
}
}
Your answer
Follow this Question
Related Questions
Create a PDF file for Android 0 Answers
open pdf on IOS 0 Answers
Application.OpenURL Android Amazon restart app when Resume 0 Answers
Create a PDF file for Android and iOS 0 Answers