![](/img/trans.png)
[英]Android - java.io.FileNotFoundException: /storage/emulated/0/Notes/File.txt: open failed: ENOENT (No such file or directory)
[英]/storage/emulated/0/Notes/ (No such file or directory)?
---- 更新答案----
我認為您無法在設備的內部存儲中創建目錄。 除非您擁有該應用程序的根訪問權限。 您只能在以下路徑 String path = getFilesDir().
內的應用程序私有文件夾中創建目錄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 。
希望這會幫助你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.