BryceSoker
BryceSoker

Reputation: 644

Android Studio Java File Not Found Exception

I tried every possible combination of paths that i could think of along with every possible location of the file. It simply does not stop going for the file Not Found exception (No file or Directory)

  try {
        String path = "D:\\Users\\[UserName]\\Desktop\\[NameofProject]\\app\\src\\main\\assets\\itemsURL";
        FileReader fileP = new FileReader(path);
        BufferedReader reader= new BufferedReader(fileP);
        for(String line; (line = reader.readLine()) != null; ) {
            filesArray.add(line);
        }
    } catch (FileNotFoundException e){
        e.printStackTrace();

Has anyone ever got this problem of, possibly, the most stubborn File Not Found exception?

java.io.FileNotFoundException: D:\Users\UserName]\Desktop\[NameofProject]\app\src\main\assets\itemsURL (No such file or directory)

File Format is like this:

 algae_banana
 boop_boop
 word_word_word
 bla_bla
 ...

Upvotes: 2

Views: 2338

Answers (1)

Wouter Vandenputte
Wouter Vandenputte

Reputation: 2103

That's not how it works. You run the app on an emulator and there is no path D:/users/... on an android Device.

Try using he Assets folder and the getAssetManager()

Upvotes: 1

Related Questions