-2

I am making an application of quotes. So can I bring data (quotes) from a csv file directly in Android? If yes please help!

zmarties
  • 4,809
  • 22
  • 39
st3alth93
  • 19
  • 4

1 Answers1

0

Yes you can easily write data from csv file,as .csv file is Comma Seperated Value file so you can get data by splitting the file by ','

  BufferedReader reader = new BufferedReader(new InputStreamReader(csv_file));
    try {
        String line;
        while ((line = reader.readLine()) != null) {
             String[] RowData = line.split(",");
             data = RowData[0];
             value = RowData[1];
            // do whatever you want to do with the data and value
        }
    }
    catch (IOException ex) {
        // handle exception
    }

finally {
    try {
        csv_file.close();
    }
    catch (IOException e) {
        // handle exception
    }
}
codeRider
  • 685
  • 1
  • 5
  • 14