First Way:
You didn't create the directory. Also, you are passing an absolute path to openFileOutput()
, which is wrong.
Second way:
You created an empty file with the desired name, which then prevented you from creating the directory. Also, you are passing an absolute path to openFileOutput()
, which is wrong.
Third way:
You didn't create the directory. Also, you are passing an absolute path to openFileOutput()
, which is wrong.
Fourth Way:
You didn't create the directory. Also, you are passing an absolute path to openFileOutput()
, which is wrong.
Fifth way:
You didn't create the directory. Also, you are passing an absolute path to openFileOutput()
, which is wrong.
Correct way:
File
for your desired directory (e.g., File path=new File(getFilesDir(),"myfolder");
)mkdirs()
on that File
to create the directory if it does not existFile
for the output file (e.g., File mypath=new File(path,"myfile.txt");
)File
(e.g., using new BufferedWriter(new FileWriter(mypath))
)