Reading CSV file in resources folder android

Sarit Adhikari picture Sarit Adhikari · Nov 14, 2013 · Viewed 21.3k times · Source

I am developing an android app in netbeans. I am trying to read CSV file using opencsv. When I put the file in resources folder and try to read it from there, there's an error while building saying invalid resource directory. Where should I store csv file so that it can be read each time the app starts?

Answer

navneet sharma picture navneet sharma · Nov 14, 2013

you should put csv file in assets folder ..

InputStreamReader is = new InputStreamReader(getAssets()
                        .open("filename.csv"));

BufferedReader reader = new BufferedReader(is);
reader.readLine();
String line;
while ((line = reader.readLine()) != null) {
                        
}