1

My Android application needs to read a CSV file which is copied to the root directory on the device (device is NOT rooted so I guess it's not the real root directory, just the directory you see when opening the device in Windows explorer).

I wonder if this is possible?

When I do this:

File file = new File("/data.csv");

if (file.exists()) {
    System.out.println("File exists!");
} else {
    System.out.println("File does NOT exist");
}

I get: "File does NOT exist"

Philippe Maes
  • 510
  • 9
  • 26

1 Answers1

3

Try this:
File file = new File(Environment.getExternalStorageDirectory()+ "/data.csv");
Make sure you include the proper READ permissions(depending on the API level you are targeting) in your AndroidManifest.xml

pri
  • 1,521
  • 2
  • 13
  • 26