Hi ! I'd like to open a file in a text editor (whichever one the user chooses/has). None of that Filestream to read line by line and write stuff, just bring me to the editor and show me the file. I've tried this : Code (csharp): string dataPath = Application.streamingAssetsPath+ "/somedoc/" + fileName; Application.OpenURL(dataPath); The code above doesn't do anything (doesn't trigger anything in the debug log or do anything). Debugging to check if System.IO.File.Exists(l_DataPath) returns false. Thing is, I'm using pretty much the same path for iOS and PC and it works. Other things I've tried : - Changing the path to Application.dataPath and Application.persistentDataPath doesn't work more. The Exists() check still returns false, but this time around a popup comes up asking me with what editor I want to open the file. Whatever I choose, once I open up the editor, it just tells me he's unable to load the file or something. - Adding "file://" or "file:///" before the path. Didn't change a thing. I'm kind of out of ideas here ! Anyone knows how to achieve this ? BONUS QUESTION : Should I finally be able to make the above work, is there a way to open the text file in readonly mode ? Thanks for anyone taking the time to help me out !
One more bump and you're going to get banned. If you post questions that don't get answers, please spend a bit of time re-wording your question or explaining the things you have done in the what? 5 hours between bumps. Typically the community don't help because they don't know what help you need. So, to help you, I guess you're assuming that every android device has a text editor. That may or may not be a safe assumption. You might need to check. On Android are you allowed to called OpenURL? The docs don't say either way, so perhaps try opening http://google.com to see if the call is permitted. Maybe you can open web pages but not arbitrary files? Also, the docs for Application.streamingAssetsPath say you'll get a URL which can be used by WWW, so may not be a regular file system path. Finally, I think you're slowly learning that devices are all different, and the way they work means that just because something works on one platform doesn't mean it'll work on another.
Finally got it working, you had it right when saying the URL can only be used by WWW. So what I did was read the file using a WWW, and simply write it in the Application.persistentDataPath. Then it could be opened using Application.OpenURL. Sorry for the bumps
Apology accepted. It's just frustrating to see people bumping their thread when 30 seconds googling or reading the docs can provide some solutions. Bumping your thread (with no extra info) just says "I am too lazy to try and help myself".
No it doesn't work since Anroid 7. https://docs.unity3d.com/ScriptReference/Application.OpenURL.html > Android: Due security changes in Android 7.0 (More information), Application.OpenURL can no longer be used for opening local app files, you need to use FileProvider which allows you to share files with other applications. You only need two slashes too. The third slash is from the root dir on system path e.g. '/usr'/... or '/C/...'
Also on android it needs to be `content://` now for custom URLs. File won't do anything. Not that URL with `content` for opening a file will work. For that you need to use it's native way. You need to create a dll and call it from it. Lame. But wateryagonnado