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.
Similar Posts:
- NPM install socket.io[UNK][UNK] error: [UNK](npm WARN enoent ENOENT: no such file or directory, open ‘/usr/local/no…
- OSError: [Errno 8] Exec format error: “No such file or directory3” or “/usr/local/bin/python3^M: bad interpreter:…
- Android Error: open failed: EACCES (Permission denied)
- [Solved] JAVA Beginners’ Error: Exception in thread “main“ java.io.FileNotFoundException
- Nacos-client Call Error: failed to create cache dir [How to Solve]
- npm WARN saveError ENOENT: no such file or directory [How to Solve]
- Socket failed:EACCES(Permission denied) [How to Solve]
- [How to Fix] file_put_contents failed to open stream
- How to Solve Chrome Error: “net::ERR_INCOMPLETE_CHUNKED_ENCODING”
- [Solved] Seata Startup Error: ErrMsg:failed to req API:/nacos/v1/ns/instance after all servers….