0

I am writing a DemoApp (mobile application) using Java in Android Studio. I am trying to read a comma separated text file using BufferedReader class. The operating system is Windows 10.

I have C:\ and D:\ drives on the laptop and I tried to move around the file from C:\ to D:\ to make it work but it did not. Android studio is installed onD:\

The file path in both the cases is verified and correct.

The user.dir system property value is \. If I try to use drive letter in the path, the absolute path becomes something like \C:/Users/currencies.txt. Therefore, I have dropped a drive letter.

I tried using both forward and backward slashes but the result is same.

Can someone help me understand how can I get rid off NoFileFoundException ?

The following is the piece of code for both the methods we tried

Sajith
  • 713
  • 6
  • 21
Hardy
  • 3
  • 2
  • where would the file live when the app is used on the target device? still on your computer? the file needs to be part of your project and loaded. – mavriksc May 21 '19 at 18:27

1 Answers1

0

Since the application is being executed in an emulator (or on a real device), it has no access to/ concept of any local file on your computer, which is why it is saying file not found. You'll need to include the file within your application. The easiest way to do that is to put it in the assets folder, such as in this example here:

https://stackoverflow.com/a/9544781/8452116

chris2112
  • 66
  • 4