I\'m doing a sample Quiz application in Android. I used array to store the Questions and Answers, now I wish to store the questions and answers in a .csv
file.
CSV stands for Comma-Separated Values. Quite good explanation can be found at wiki: CSV. Since you're programming on Android platform consider using one of availible Java libraries such as OpenCSV or JavaCSV.
Put you .csv in the assert folder and access it as follow
I was using .csv to get the list of counter in my application..
public ArrayList<String> COUNTRIES = new ArrayList<String>();
try {
is = res.getAssets().open("country.csv");
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = reader.readLine()) != null)
COUNTRIES.add(line);
}
catch (IOException ex) {
// handle exception
}
finally {
try {
is.close();
}
catch (IOException e) {
// handle exception
}
}
CSV, comma separated values, files are commonly used to transport large amounts of tabular data between either companies or applications that are not directly connected. The files are easily editable using common spreadsheet applications like Microsoft Excel.
Read more
And take a look at these Samples on reading / writing *.csv
.
I think this is general discussion, (Not specific to android)
The CSV ("Comma Separated Value") file format is often used to exchange data between disparate applications. The file format, as it is used in Microsoft Excel, has become a pseudo standard throughout the industry, even among non-Microsoft platforms.
There are many ways to generate a csv file. A csv file is a comma delimited data file. Many applications such as Excel or MS Access allow one to save data in csv format. But you can also generate csv files yourself as long as the data is comma delimited and each line is ended with a line break.
For more look at Here and For Android use OpenCSV library.