Reading files in android. how to fix bad path
<p>I am trying to read a file in android.
I am used to doing this in java but here I am getting a <strong>open failed enoent (no such file or directory)</strong> error.
I am not sure how to import the file. Should I put it in the same directory as my application? right now its on my desktop.
here is my code</p>

<pre><code>package com.androidplot.fun;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class ReadFile {
    private String path;
    public ReadFile(String file_path){
        path = file_path;
    }
    public String[] OpenFile() throws IOException{
        FileReader fr = new FileReader(path);
        BufferedReader textReader = new BufferedReader(fr);
        int numberOfLines = 3;
        String[ ] textData = new String[numberOfLines];
        int i;
        for (i=0; i &lt; numberOfLines; i++) {
            textData[ i ] = textReader.readLine();
        }
        textReader.close( );
        return textData;
    }
    int readLines() throws IOException{
        FileReader file_to_read = new FileReader(path);
        BufferedReader bf = new BufferedReader(file_to_read);

        String aLine;
        int numberOfLines = 0;
        while (( aLine = bf.readLine()) != null){
            numberOfLines++;
        }
        bf.close();
        return numberOfLines;
    }

}
</code></pre>

<p>This is the class I've been using. And this is what I am using in my main program</p>

<pre><code>try{
    ReadFile file = new ReadFile("/Users/jonathon/Desktop/data.txt");
    String[] aryLines = file.OpenFile();
    int x;
    for ( x=0; x &lt; aryLines.length; i++ ) {
      System.out.println( aryLines[ i ] ) ;
    }
 }
 catch ( IOException e ) {
   System.out.println( e.getMessage() );
 }
</code></pre>
