To Examples
WriteToFile Example
Goal
Write to a file in Internal Storage. Write string in
EditText
widget to file. Then read from file and display it in a
TextView
widget.
Directions
Create an Android project named WriteToFile. Use this layout file:
activity_main.xml
Use this Java Activity file:
MainActivity.java
To create a file in internal storage, use this line:
file = new File(getFilesDir( ), fileName);
Internal Storage disk space on a device or emulator for storing files.
Information about internal storage:
It's always available.
Files saved here are accessible by only your app.
When the user uninstalls your app, the system removes all your app's files from internal storage.
Internal storage is best when you want to be sure that neither the user nor other apps can access your files.