我尝试了这个链接:
How to create text file and insert data to that file on Android
但是,它说“没有这样的文件或目录”。有人可以帮我吗?提前致谢!
最佳答案
----更新答案----
我认为您无法在设备的内部存储中创建目录。除非您拥有该应用程序的 root 访问权限。您只能在以下路径 String path = getFilesDir().
你可以像下面这样使用 -
File mydir = context.getDir("mydirectory", Context.MODE_PRIVATE); //Creating an internal dir;
File fileWithinMyDir = new File(mydir, "myAwesomeFile"); //Getting a file within the dir.
FileOutputStream out = new FileOutputStream(fileWithinMyDir); //Use the stream as usual to write into the file.
getDir(StringName, int mode)
方法用于创建或访问内部存储中的目录。
/storage/emulated/0/Notes/将始终返回 No such file or directory
,除非设备已获得 root 权限,并且 dir.mkDirs()
对此路径将始终返回 false。
希望这对您有帮助。
关于java -/storage/emulated/0/Notes/(没有这样的文件或目录)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60273173/