title: How to write my file to the Android directory
body: <p>This is just an early stage test of creating and writing a file to the project directory. I thought this was going to go really quick, but either I'm doing something wrong or perhaps I'm not updating something properly?</p>
  
  <p>All I want to do is to be able to dynamically create and write a file to my raw folder.</p>
  
  <p>I use a couple of methods for other things such as getting my ArrayList of objects, using a for loop to get them individually, and then using "write" to write to the file.</p>
  
  <p>Here is my code: The file I want to create and write to is called a txt file called output.</p>
  
  <p>I really appreciate anyone looking at this for me, thank you very much!</p>
  
  <pre><code>//for writing file...
    public static void writeGrids(List&lt;Grid&gt; grids)
    {
        for(int i = 0; i &lt; grids.size(); i++)
        {
  
            try {
              write(grids.get(i));
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
        }
    }
  
   static void write(Grid grid) throws IOException
    {
  
       try
       {
       FileWriter fstream = new FileWriter("/My Project/res/raw/output.txt");
       BufferedWriter out = new BufferedWriter(fstream);
       //FILE DIR!!!!!!
  
            out.write(grid.gridNickName + ";" + grid.gridName + ";" +
                    grid.firstName + ";" + grid.lastName + ";" +
                    grid.password + ";" + grid.loginURI + ";");
  
       out.close();
       }
       catch (Exception e)
       {
           System.err.println("Error: " + e.getMessage());
       }
  
    }
  </code></pre>
  
  <p>This is an updated version of trying to save something to the internal storage. Would this be an ideal solution?</p>
  
  <p>UPDATED CODE:</p>
  
  <pre><code>//for writing file...
  public void writeGrids(List&lt;Grid&gt; grids)
  {
        for(int i = 0; i &lt; grids.size(); i++)
        {
  
            try {
              write(grids.get(i));
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
        }
  }
  
  void write(Grid grid) throws IOException
  {    
  
       try
       {
        FileOutputStream fos;
       String FILENAME = "InternalString";
  
       fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
       String data = grid.getGridNickName() + ";" + grid.getGridName() + ";" +
                grid.getFirstName() + ";" + grid.getLastName() + ";" +
                grid.getPassword() + ";" + grid.getLoginURI() + ";";
       fos.write(data.getBytes());
       fos.close();
  
       }
       catch (Exception e)
       {
           System.err.println("Error: " + e.getMessage());
       }
  
  }
  </code></pre>
  
  <p>The user would call the write method to get things started like so.. writeGrids(myNewArrayList);</p>