Tag Archives: createNewFile()

CreateNewFile() error: open failed: ENOENT (No such file or directory) solution

I encountered an open failed: ENOENT (No such file or directory) error when using createNewFile() in writing an Android application. I checked many methods on the Internet, but none of them could solve my problem. Finally, I found the problem, so I wrote a summary.

First, summarize the common solutions on the Internet:

1. Level directory problem

mkdir() does not work, mkdirs() should be used;

2. Permission issues

Above API23+, not only need to add permissions in AndroidManifest.xml, but also request permissions in JAVA code.

 

The above is the common solution on the Internet, and my question is:

3. File naming problem

Through createNewFile(), the naming convention must also be followed. If an illegal symbol is included, an open failed: ENOENT (No such file or directory) error will also be reported.