Q:

Choose text file and Read Android

I chose a text file from storage and got its path (FilePath), am trying to read the content of that text file and put it in edittext..i am using the code below to get text file data and put it in edittext (eTPronounce)
 File sdcard = Environment.getExternalStorageDirectory();

//Get the text filea
                File file = new File(sdcard,FilePath);

//Read text from file
                StringBuilder text = new StringBuilder();

                try {
                    BufferedReader br = new BufferedReader(new FileReader(file));
                    String line;

                    while ((line = br.readLine()) ! = null) {
                        text.append(line);
                        text.append('\n');
                    }
                    br.close();
                }
                catch (IOException e) {
                    //You'll need to add proper error handling here
                }

//Find the view by its i

//Set the text
           eTPronounce.setText(text);

            }
        });

If i replace  FilePath (in the second line) with any directory where there is text file it works. For example if I replace FilePath with "Download/text.txt" it works . 
I used this link to get FilePath 
THANKS

A:

I think you should be using below constructor
File(File dir, String name)

or you can use
File(String path)

If you are specifying directory name then you only need to give the file name as shown in the first example. Otherwise you can use the second one with the complete file path

