Create a file/pad in the internal memory(internal storage)
-
I'm trying to create a file:
File path=new File(getFileDir(),"MyFolder"); OutputStreamWriter out; try { File f=new File(path,"my.txt"); out=new OutputStreamWriter(openFileOutput(f.getPath,MODE_PRIVATE)); out.write("test"); out.close(); }catch(IOException e) { e.printStackTrace(); }
It's not working. Please explain where the mistake is and how to do it right.
-
If you didn't mention the manifesto on the question, then your mistake is that you didn't add the necessary permits to him.
Add this authorization in the main line of the manifest:
<manifest ...> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ... </manifest>