簡體   English   中英

/storage/emulated/0/Notes/(沒有那個文件或目錄)?

[英]/storage/emulated/0/Notes/ (No such file or directory)?

我試過這個鏈接:

如何在 Android 上創建文本文件並將數據插入該文件

但是,它說“沒有這樣的文件或目錄”。 有人可以幫我嗎? 提前致謝!

---- 更新答案----

我認為您無法在設備的內部存儲中創建目錄。 除非您擁有該應用程序的根訪問權限。 您只能在以下路徑 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM