title: Trouble with reading file from assets folder in Android
body: <p>This question is with regards to <a href="https://stackoverflow.com/questions/9657763/where-to-save-text-file-to-be-able-to-read-it-into-android-project">this one</a>. Since it is a specific question I moved that question by itself here. I have tried creating a text file, "foo.txt", an read it into my Activity doing:</p>
  
  <pre><code>File file = new File("/assets/foo.txt");
  if ( file.exists() ){
      txtView.setText("Exists");
  }
  else{
      txtView.setText("Does not exist");
  }
  </code></pre>
  
  <p>The "foo.txt" file is located in my assets folder and I have verified that it exists in the OS. My TextView always gets the text "Does not exist" from the code above. I have tried going</p>
  
  <pre><code>File file = new File("/assets/foo.txt");
  Scanner in = new Scanner(file);
  </code></pre>
  
  <p>as well, but this produces the following <strong>inline</strong> error: "Unhandled exception type FileNotFoundException". Eclipse then suggest to involve try/catch, which removes the error but it doesn't work properly then either.</p>
  
  <p>I have also tried setting my assets folder to "Use as source folder", but this does not make any difference. I have also tried using a raw folder as several people suggests to no use. I am out of options and really need help for this one. Should be easy...</p>
  
  <p>Another try is to go</p>
  
  <pre><code>AssetManager assetManager = getResources().getAssets();
  InputStream is = assetManager.open("assets/foo.txt");
  </code></pre>
  
  <p>but this produces the <strong>inline</strong> error in the second line: "Unhandled exception type IOException".</p>