To Examples

WriteToFile Example

Goal

Directions

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