1. Are you ready for the Galaxy S20? Here is everything we know so far!

Apps Write to <appdir>/files/<anysubdir> robustly?

Discussion in 'Android Development' started by Wolf2000me, Feb 13, 2011.

  1. Wolf2000me

    Wolf2000me Lurker
    Thread Starter


    I'm working on an application that involves writing files to the private files dir of an application. In the first stage I only had to write to the default files dir so I just used the openFileInput() method from an Activity (Context). Now that I've done that I was about to expand and write files in different directories for different purposes. This resulted in:

    "java.lang.IllegalArgumentException: File foo/bar.txt contains a path separator"

    This stackoverflow question explains the problem nicely. The suggested solution probably works but I'm wondering how I should implement it. I would like to feature the permissions and anything else that I might require to have robust I/O.

    android - How to create files hierarchy in Anroids &#39;/data/data/pkg/files&#39; directory? - Stack Overflow

    Also, in my experience, when API developers prohibit such a feature there's a reason for it. So if anyone has any thoughts on that, by all means enlighten me :)




Share This Page