Search code examples
androidopencsv

Reading CSV file in resources folder android


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?


Solution

  • 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) {
                            
    }