Android – Generate CSV file from table values

You can use opencsv for this

Download the library from here:

http://sourceforge.net/projects/opencsv/

In this you can find jar file.

Inside your activity use this:

CSVWriter writer = null;
try 
{
    writer = new CSVWriter(new FileWriter("/sdcard/myfile.csv"), ',');
    String[] entries = "first#second#third".split("#"); // array of your values
    writer.writeNext(entries);  
    writer.close();
} 
catch (IOException e)
{
    //error
}

Leave a Comment