使用按钮将sqlite db导出到excel可读文件(也许是csv)?

使用按钮将sqlite db导出到excel可读文件(也许是csv)?,第1张

概述我将本教程(http://www.screaming-penguin.comode/7749)改编为我构建的Android应用程序,允许按下按钮将当前数据库导出到用户的SD卡.它完美无瑕.但我担心我的应用程序的用户不熟悉db文件,我正在寻找一种方法将其转换为更加用户友好的格式.我遇到了这个主题(http://groups.google

我将本教程(http://www.screaming-penguin.com/node/7749)改编为我构建的Android应用程序,允许按下按钮将当前数据库导出到用户的SD卡.它完美无瑕.

但我担心我的应用程序的用户不熟悉db文件,我正在寻找一种方法将其转换为更加用户友好的格式.我遇到了这个主题(http://groups.Google.com/group/androID-beginners/browse_thread/thread/4e53ebca14daecfc),它建议“从数据库中查询数据并将数据写入csv文件”.

我希望有人能指出我正确的方向,开始弄清楚如何做到这一点.我发现很难找到有关特定方法的更多信息.

或者只是简单地解释如何阅读和访问.db文件更有意义?

谢谢

编辑:我也有一个关于sqlite导出过程的问题,我想我只是在这里问,而不是创建一个新的问题.有没有办法修改下面的代码,以便每个导出将接收日期的字符串表示或只附加一个数字?现在,如果您再次导出,它会自动覆盖旧文件.谢谢.

protected Boolean doInBackground(final String... args) {        file dbfile = new file(Environment.getDataDirectory() +                 "/data/com.example.example/databases/data");        file exportDir = new file(Environment.getExternalStorageDirectory(), "exampledata");        if (exportDir.exists()) {            exportDir.mkdirs();        }        file file = new file(exportDir, dbfile.getname());        try {            file.createNewfile();            this.copyfile(dbfile, file);            return true;        } catch(IOException e) {            Log.e(MyApplication.APP_name, e.getMessage(), e);            return false;        }    }

解决方法:

I was hoPing someone Could point me in the right direction to begin figuring out how to do this.

要读入数据,请使用rawquery().

要编写数据,请使用Java I/O.还有适用于Java的open source CSV libraries可用于AndroID.

Is there a way to modify the code below so that each export would receive either a string representation of the date or just a single numeral appended to it?

使用字符串连接将您想要的任何内容添加到文件名中.

另外,请摆脱:

file dbfile = new file(Environment.getDataDirectory() +                 "/data/com.example.example/databases/data");

并替换为:

file dbfile=getDatabasePath("data");

总结

以上是内存溢出为你收集整理的使用按钮将sqlite db导出到excel可读文件(也许是csv)?全部内容,希望文章能够帮你解决使用按钮将sqlite db导出到excel可读文件(也许是csv)?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1117571.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存