Android的 - 从生成表中的值CSV文件 [英] Android - Generate CSV file from table values

查看:105
本文介绍了Android的 - 从生成表中的值CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含一个表的数据库,我要生成CSV文件与此表中的值。

I am having a database containing one table, i want to generate CSV file with values of this table.

其实,我要通过电子邮件发送这个CSV文件作为附件。我知道有关发送文件作为附件的电子邮件的意图(AcTION_SEND),但我不知道在创建或通过它我可以创建CSV格式文件的方法的过程。

Actually, I want to email this CSV file as an attachment. I know about sending file as an attachment in Email intent(AcTION_SEND), but i dont know the procedure of creating or the method by which i can create CSV formatted file.

请给我任何建议或想法。

Please give me suggestions or ideas.

推荐答案

您可以使用 opencsv

You can use opencsv for this

从这里下载库:

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

在此,你可以找到jar文件。

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
}

这篇关于Android的 - 从生成表中的值CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆