How to read in the android application a CSV file previously embedded?

0

I'm having difficulty getting this part done, I've followed all the steps of several sites, I've reached the end and the application reads the file. Anyone know what might be happening ??

    
asked by anonymous 28.05.2018 / 15:07

1 answer

1

Good afternoon Leandro,

I found this article that might be relevant:

link

The following code will be from the response given as correct:

public final List<String[]> readCsv(Context context) {
List<String[]> questionList = new ArrayList<String[]>();
AssetManager assetManager = context.getAssets();

try {
InputStream csvStream = assetManager.open(CSV_PATH);
InputStreamReader csvStreamReader = new InputStreamReader(csvStream);
CSVReader csvReader = new CSVReader(csvStreamReader);

String[] line;

// throw away the header
csvReader.readNext();

while ((line = csvReader.readNext()) != null) {
questionList.add(line);
}

} catch (IOException e) {

e.printStackTrace();

}

return questionList;

}

I hope I have helped.

    
28.05.2018 / 15:21