user896692
user896692

Reputation: 2371

FileNotFoundException - reading csv file

I´m writing on a quite simple Android app but I can´t find the error in my code. Here is my code that I can import data from a csv file:

 public String[] csvread() throws IOException {

        String aktzeile;
        String zeilen[] = new String[200];
        BufferedReader br = new BufferedReader(new FileReader("fragenbronze.csv"));
        while((aktzeile = br.readLine()) != null) {
            zeilen = aktzeile.split(",");
        }
     return zeilen;
    }

The csv file "fragenbronze.csv" is is located at app - build - intermediates - assets

Is the assets folder the wrong folder? Google tells me that I should place it there.

Upvotes: 1

Views: 75

Answers (1)

Menelaos Kotsollaris
Menelaos Kotsollaris

Reputation: 5506

To access the asset folder, use AssetManager.

Example:

InputStream input = assetManager.open("fragenbronze.csv");
AssetManager assetManager = getAssets();

Upvotes: 2

Related Questions