This is my noob question for the week. I'm looking more for general speculation than specific code and maybe hoping the Android folks are watching and could correct this:
the SDK documentation for Context.openFileOutput says:
Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist.
Ok, that sounds good. I can create a file. Except this method also throws a FileNotFoundException, so apparently something is amiss. Why would a function that is supposed to create a file if it's not found throw an exception if the file is not found???
Kinda defeats that whole "Creates the file..." thing, doesn't it?
I have to apologize for leaping before I looked on this one. I kinda panicked while reading the documentation. After some testing, I found that openFileOutput()
does, in fact, work as advertised and will create a file if it's not found, not just throw an FnF exception as I feared. Apparently, the FnF throw was added in case the Activity's application directory does not exist.
Again, my apologies but hopefully, this might help others who are confused by the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With