title: How to create, write, and read a file on Android and then access it on the device?
body: <p>I'm trying to access a text file on my android device. I have successfully written to and read from the file in my code, but I want to be able to access the file so that I can copy and move it elsewhere.</p>
  
  <p>My code is included below and there are no errors when I run it. However, it is just the base code that I have made numerous edits to, to try and solve this.</p>
  
  <p>Though it is not shown, the default method onCreate runs createFile(), writeFile("Hello File!"), and readFile() all in order after the default code that is contained in the method.</p>
  
  <pre><code>Context context = this;
  
  String autoFileName = "AutoDataFile.txt";
  File path;
  File myFile;
  
  String insideText = "NOTHING";
  
  public void createFile(){
      path = context.getFilesDir();
      myFile = new File(path, autoFileName);
  }
  
  public void writeFile(String text){
      try {
          FileOutputStream stream = new FileOutputStream(myFile);
          stream.write(text.getBytes());
          stream.write(",".getBytes());
          stream.write("Second input!".getBytes());
          stream.close();
          System.out.println("SUCCESS?: MAY HAVE WRITTEN TO FILE");
      } catch (Exception e){
          e.printStackTrace();
          System.out.println("ERROR: DID NOT WRITE TO FILE");
      }
  }
  
  public void readFile(){
      try {
          Scanner fileStream = new Scanner(myFile);
          insideText += " " + fileStream.useDelimiter(",").nextLine();
          System.out.println("SUCCESS?: MAY HAVE READ FROM FILE");
      } catch (FileNotFoundException e) {
          e.printStackTrace();
          System.out.println("ERROR: DID NOT READ FROM FILE");
      }
  }
  </code></pre>