Home » Android » java – /storage/emulated/0/Notes/ (No such file or directory)?-Exceptionshub

java – /storage/emulated/0/Notes/ (No such file or directory)?-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment


I tried this link:

How to create text file and insert data to that file on Android

But, it says “No such file or directory”. Can anybody help me please? Thanks in advance!

How to&Answers:

—- Updated answer—-

I think you can’t create a directory inside the internal storage of the device. Except you’ve a root access for the app. You can only create the directory inside your app private folder within the following path String path = getFilesDir().

you can use like this below –

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) method to create or access directories in internal storage.

/storage/emulated/0/Notes/ will always return No such file or directory except device is rooted and dir.mkDirs() will always return false for this path.

Hope this will help you.