Sarit Adhikari Sarit Adhikari - 1 month ago 20
Android Question

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?

Answer

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

                    }
Comments