Reading a text file from the assets folder in android
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/9674815/trouble-with-reading-file-from-assets-folder-in-android">Trouble with reading file from assets folder in Android</a>  </p>
</blockquote>



<p>Hey I'm trying to read a file from the assets folder in android and this is what i have so far  </p>

<pre><code>public class TestingMusicDAO {

private static final String TAG_NAME = "MUSIC_TESTING_DAO";
private static List&lt;Song&gt; songs;
private ContentResolver contentResolver;
private static Context testingcontext;
private File fFile;
InputStream inputStream = null;


public TestingMusicDAO( Context context) throws IOException{
    Log.d(TAG_NAME, "Setting up testing songs");
    contentResolver = context.getContentResolver();
    testingcontext = context;
    getAllSongsFromFile();

}

public static void getAllSongsFromFile() throws IOException{
    Log.d( TAG_NAME, "Tryign to Get all Songs" );
    InputStream is;

    is = testingcontext.getAssets().open("testing");
    Log.d( TAG_NAME, "Did that work?" );
    BufferedReader bufferReader = new BufferedReader(new InputStreamReader(is));
    String inputLine;
    while((inputLine = bufferReader.readLine()) != null){
        processLine(inputLine);
    }
    bufferReader.close();

}

private static void logSongs() {
    for(Song song : songs)
        Log.d( TAG_NAME, song.toString() );
}

public List&lt;Song&gt; getAllSongs() {
    return songs;
}

public static void processLine(String aLine) {
    Scanner scanner = new Scanner(aLine);
    scanner.useDelimiter("=");
    if(scanner.hasNext()){
        String title = scanner.next();
        String artist = scanner.next();
        String album = scanner.next();
        String id = scanner.next();
        String albumId = scanner.next();
        String trackOrder = scanner.next();
        Log.d(TAG_NAME, "Title = " + title + "Artist = " + artist + "Album = " + album + "ID = " + id + "AlbumID = " + albumId);
    }
    else {
        Log.d(TAG_NAME, "Empty or invalid line. Unable to process");
    }


}

}
</code></pre>

<p>So I basically call the TestingMusicDAO constructor and from there I want to read each line of the file individually to be able to parse them but it keeps giving me a FileNotFoundExecption: testing. Any ideas would be great thanks!</p>

<p>Peter,</p>
